diff --git a/.gitignore b/.gitignore index 6ae46dd..6dce2cc 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ *.swp *.obj *.moc -*.ui +.ui *~ moc_* promoe.app diff --git a/src/dialogs/dialogs.pri b/src/dialogs/dialogs.pri index c2358e0..e1a033c 100644 --- a/src/dialogs/dialogs.pri +++ b/src/dialogs/dialogs.pri @@ -1,10 +1,13 @@ -HEADERS += playlistchooser.h \ +HEADERS += entryinfo.h \ + playlistchooser.h \ urlopen.h -SOURCES += playlistchooser.cpp \ +SOURCES += entryinfo.cpp \ + playlistchooser.cpp \ urlopen.cpp -FORMS += playlistchooser.ui \ +FORMS += entryinfo.ui \ + playlistchooser.ui \ urlopen.ui INCLUDEPATH += $$PWD diff --git a/src/dialogs/entryinfo.cpp b/src/dialogs/entryinfo.cpp new file mode 100644 index 0000000..b90612b --- /dev/null +++ b/src/dialogs/entryinfo.cpp @@ -0,0 +1,84 @@ +/** + * This file is a part of promoe, an XMMS2 client + * + * Copyright (C) 2008 Thomas Frauendorfer + * + * 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. + */ + +#include "xclientcache.h" + +#include "entryinfo.h" + +#include +#include +#include + +EntryInfo::EntryInfo (QWidget *paren, XClientCache *cache, uint32_t id) +{ + setupUi (this); + setAttribute (Qt::WA_DeleteOnClose); + + m_cache = cache; + m_id = id; + + connect (cache, SIGNAL (entryChanged (uint32_t)), + this, SLOT (mlib_entry_changed (uint32_t))); + + connect (cache, SIGNAL (entryRemoved (uint32_t)), + this, SLOT (mlib_entry_removed (uint32_t))); + + getInfo (); +} + +void +EntryInfo::getInfo () +{ + QHash tmp = m_cache->get_info (m_id); + + //FIXME "url" value ist wrong. tight be an error in clientcache + filenameEdit->setText (tmp.value ("url").toString ()); + titleEdit->setText (tmp.value ("title").toString ()); + artistEdit->setText (tmp.value ("artist").toString ()); + albumEdit->setText (tmp.value ("album").toString ()); + // commentEdit->setText (); + yearEdit->setText (tmp.value ("date").toString ()); + trackEdit->setText (tmp.value ("tracknr").toString ()); + genreEdit->setText (tmp.value ("genre").toString ()); +} + +void +EntryInfo::setId (uint32_t id) +{ + m_id = id; + getInfo (); +} + +void +EntryInfo::mlib_entry_changed (uint32_t id) +{ + if (id == m_id) { + // the metadata for the current entry changed, + // so we update the dialog to display the current values + // TODO: think of a good way to handle changed values as soon as + // we allow editing of metadata + getInfo (); + } +} + +void +EntryInfo::mlib_entry_removed (uint32_t id) +{ + // if the mlib no longer contains our item, we have to remove it + if (id == m_id) { + close (); + } +} diff --git a/src/dialogs/entryinfo.h b/src/dialogs/entryinfo.h new file mode 100644 index 0000000..ff240a9 --- /dev/null +++ b/src/dialogs/entryinfo.h @@ -0,0 +1,46 @@ +/** + * This file is a part of Promoe, an XMMS2 client + * + * Copyright (C) 2008 Thomas Frauendorfer + * + * 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. + */ + +#ifndef __ENTRYINFO_H__ +#define __ENTRYINFO_H__ + +#include "ui_entryinfo.h" + +#include + +class XClientCache; + +class EntryInfo : public QDialog, private Ui::EntryInfo { + Q_OBJECT + + public: + EntryInfo (QWidget *parent, XClientCache *cache, uint32_t id = 0); + + public slots: + void setId (uint32_t id); + + private slots: + void mlib_entry_changed (uint32_t id); + void mlib_entry_removed (uint32_t id); + + private: + void getInfo (); + + uint32_t m_id; + XClientCache *m_cache; +}; + +#endif diff --git a/src/dialogs/entryinfo.ui b/src/dialogs/entryinfo.ui new file mode 100644 index 0000000..4892291 --- /dev/null +++ b/src/dialogs/entryinfo.ui @@ -0,0 +1,224 @@ + + EntryInfo + + + + 0 + 0 + 426 + 357 + + + + Dialog + + + + + + + + Filename: + + + + + + + true + + + + + + + + + + 0 + 0 + + + + ID Tag: + + + + + + Title: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + + + + + Artist: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + + + + + Album: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + + + + + Comment: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + + + + + Year: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 80 + 16777215 + + + + true + + + + + + + Track Number: + + + + + + + true + + + + + + + Genre: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + buttonBox + accepted() + EntryInfo + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + EntryInfo + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/mainwindow/maindisplay.cpp b/src/mainwindow/maindisplay.cpp index 7a4c85b..4ad77f6 100644 --- a/src/mainwindow/maindisplay.cpp +++ b/src/mainwindow/maindisplay.cpp @@ -256,7 +256,6 @@ MainDisplay::SetupToggleButtons (void) m_repeat->move(210, 89); connect (m_repeat, SIGNAL (clicked (bool)), this, SLOT (setRepeatAllEnabled (bool))); - //m_repeat->setEnabled(false); // FIXME: Disabled button for now, not yet implemented } diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index 1e2ffc8..60ed06a 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -23,6 +23,7 @@ #include "playlistmodel.h" #include "playlistwidget.h" #include "Skin.h" +#include "entryinfo.h" #include #include @@ -142,6 +143,9 @@ PlaylistView::PlaylistView (QWidget *parent) : QListView (parent) connect (&xmmsh, SIGNAL(playbackStatusChanged(Xmms::Playback::Status)), this, SLOT(handleStatus(Xmms::Playback::Status))); + + connect (this, SIGNAL (clicked (QModelIndex)), + this, SLOT (on_item_clicked (QModelIndex))); } void @@ -182,7 +186,7 @@ PlaylistView::contextMenuEvent (QContextMenuEvent *e) a = new QAction (tr ("Show file info"), this); a->setShortcut (tr ("Ctrl+Enter")); - a->setEnabled(false); // FIXME: Disabled for now + connect (a, SIGNAL (triggered ()), this, SLOT (showEntryInfo ())); qm.addAction (a); qm.addSeparator (); @@ -278,3 +282,33 @@ PlaylistView::mouseDoubleClickEvent (QMouseEvent *event) xmmsh.xplayback ()->play (); } } + +void +PlaylistView::showEntryInfo (void) +{ + XMMSHandler &client = XMMSHandler::getInstance (); + QModelIndex current = selectionModel ()->currentIndex (); + if (current.isValid ()) { + uint32_t id = model ()->data (current, PlaylistModel::MedialibIdRole) + .toUInt (); + // If no infodialog exists, create one, else set the selected Item as + // displayed item + if (!m_entry_info) { + m_entry_info = new EntryInfo (this, client.cache (), id); + } else { + m_entry_info->raise (); + m_entry_info->setId (id); + } + m_entry_info->show (); + } +} + +void +PlaylistView::on_item_clicked (QModelIndex index) +{ + if (m_entry_info) { + uint32_t id = model ()->data (index, PlaylistModel::MedialibIdRole) + .toUInt (); + m_entry_info->setId (id); + } +} diff --git a/src/playlist/playlistview.h b/src/playlist/playlistview.h index 6a884c2..81b5b7b 100644 --- a/src/playlist/playlistview.h +++ b/src/playlist/playlistview.h @@ -19,12 +19,15 @@ //include "Playlist.h" #include +#include class Skin; #include #include #include +#include class QWidget; +class QModelIndex; class PlaylistDelegate : public QAbstractItemDelegate { Q_OBJECT @@ -57,12 +60,16 @@ class PlaylistView : public QListView { void invertSelection (void); void cropSelected (void); void removeSelected (void); + void showEntryInfo (void); void settingsSaved (void); void setPixmaps (Skin *skin); protected: void mouseDoubleClickEvent (QMouseEvent *event); + private slots: + void on_item_clicked (QModelIndex index); + private: Xmms::Playback::Status m_status; QFont *m_font; @@ -71,6 +78,7 @@ class PlaylistView : public QListView { QColor m_color_selected; QColor m_color_normal; QColor m_color_normal_bg; + QPointer m_entry_info; }; diff --git a/src/playlist/playlistwidget.cpp b/src/playlist/playlistwidget.cpp index 91a5c4e..42d1298 100644 --- a/src/playlist/playlistwidget.cpp +++ b/src/playlist/playlistwidget.cpp @@ -273,6 +273,8 @@ PlaylistWidget::addButtons (void) Skin::PLS_MSC_SRT_1); b = new PlaylistMenuButton (m_msc, Skin::PLS_MSC_INF_0, Skin::PLS_MSC_INF_1); + connect (b, SIGNAL (activated ()), + m_view, SLOT (showEntryInfo ())); b = new PlaylistMenuButton (m_msc, Skin::PLS_MSC_OPT_0, Skin::PLS_MSC_OPT_1); /* playlist menu */