From e1e809d8fbd552639f1abe1c4f86b0dcc31c4175 Mon Sep 17 00:00:00 2001 From: Thomas Frauendorfer Date: Sun, 10 Feb 2008 10:35:57 +0100 Subject: [PATCH] added dialog to add urls --- lib/xcollection.cpp | 19 +++++++ lib/xcollection.h | 2 + src/dialogs/dialogs.pri | 9 ++-- src/dialogs/urlopen.cpp | 45 ++++++++++++++++ src/dialogs/urlopen.h | 41 +++++++++++++++ src/dialogs/urlopen.ui | 93 +++++++++++++++++++++++++++++++++ src/playlist/playlistwidget.cpp | 11 ++++ src/playlist/playlistwidget.h | 2 +- src/src.pro | 1 + 9 files changed, 219 insertions(+), 4 deletions(-) create mode 100644 src/dialogs/urlopen.cpp create mode 100644 src/dialogs/urlopen.h create mode 100644 src/dialogs/urlopen.ui diff --git a/lib/xcollection.cpp b/lib/xcollection.cpp index 91a0833..a4bdf93 100644 --- a/lib/xcollection.cpp +++ b/lib/xcollection.cpp @@ -17,6 +17,7 @@ #include #include +#include XCollection::XCollection (XClient * client) : QObject ( client) { @@ -162,3 +163,21 @@ XCollection::addIdlist (QString name) { return true; } + +bool +XCollection::playlistAddUrl (QUrl url, QString plsname) +{ + //TODO: more tests if file is valid + if (!url.isValid ()) { + return false; + } + + if (plsname == "") { + plsname = m_activePlaylist; + } + + m_client->playlist ()->addUrl (url.toString ().toStdString (), + plsname.toStdString ()); + + return true; +} diff --git a/lib/xcollection.h b/lib/xcollection.h index 4fa9661..f978a83 100644 --- a/lib/xcollection.h +++ b/lib/xcollection.h @@ -21,6 +21,7 @@ #include class QString; class QStringList; +class QUrl; class XCollection : public QObject { @@ -35,6 +36,7 @@ class XCollection : public QObject bool setActivePlaylist (QString name); QString activePlaylist () {return m_activePlaylist;} bool addIdlist (QString name); + bool playlistAddUrl (QUrl url, QString plsname = ""); signals: void collectionModified (QString collection, QString ns, int type, diff --git a/src/dialogs/dialogs.pri b/src/dialogs/dialogs.pri index 15b00ab..c2358e0 100644 --- a/src/dialogs/dialogs.pri +++ b/src/dialogs/dialogs.pri @@ -1,8 +1,11 @@ -HEADERS += playlistchooser.h +HEADERS += playlistchooser.h \ + urlopen.h -SOURCES += playlistchooser.cpp +SOURCES += playlistchooser.cpp \ + urlopen.cpp -FORMS += playlistchooser.ui +FORMS += playlistchooser.ui \ + urlopen.ui INCLUDEPATH += $$PWD DEPENDPATH += $$PWD diff --git a/src/dialogs/urlopen.cpp b/src/dialogs/urlopen.cpp new file mode 100644 index 0000000..492096a --- /dev/null +++ b/src/dialogs/urlopen.cpp @@ -0,0 +1,45 @@ +/** + * 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. + */ + +// FIXME: because somewhere something with the includes is wrons, this line +// is needed +#include "XMMSHandler.h" + +#include + +#include "urlopen.h" +#include "xcollection.h" + +UrlOpen::UrlOpen (QWidget *parent, XCollection *coll) : QDialog (parent) +{ + setupUi (this); + setAttribute (Qt::WA_DeleteOnClose); + + m_collection = coll; +} + +void +UrlOpen::on_openButton_clicked () +{ + QUrl url(urlEdit->text ()); + + if (url.isValid ()) { + bool b = m_collection->playlistAddUrl (url); + if (b) { + close (); + } + } +} diff --git a/src/dialogs/urlopen.h b/src/dialogs/urlopen.h new file mode 100644 index 0000000..78e6267 --- /dev/null +++ b/src/dialogs/urlopen.h @@ -0,0 +1,41 @@ +/** + * 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 __URLOPEN_H__ +#define __URLOPEN_H__ + +#include "ui_urlopen.h" + +#include + +class XCollection; + +class UrlOpen : public QDialog, private Ui::UrlOpen { + Q_OBJECT + + public: + UrlOpen (QWidget *parent, XCollection *coll); + + private slots: + // autoconnect slots + void on_openButton_clicked (); + + private: + XCollection *m_collection; + +}; + +#endif diff --git a/src/dialogs/urlopen.ui b/src/dialogs/urlopen.ui new file mode 100644 index 0000000..0636912 --- /dev/null +++ b/src/dialogs/urlopen.ui @@ -0,0 +1,93 @@ + + UrlOpen + + + + 0 + 0 + 328 + 81 + + + + + 0 + 0 + + + + Open Url + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Open + + + + + + + Close + + + + + + + + + + + urlEdit + returnPressed() + openButton + click() + + + 203 + 25 + + + 207 + 53 + + + + + closeButton + clicked() + UrlOpen + close() + + + 261 + 60 + + + 56 + 57 + + + + + diff --git a/src/playlist/playlistwidget.cpp b/src/playlist/playlistwidget.cpp index 91d12c8..739ac6c 100644 --- a/src/playlist/playlistwidget.cpp +++ b/src/playlist/playlistwidget.cpp @@ -27,6 +27,7 @@ #include "playlistmenu.h" #include "FileDialog.h" #include "playlistchooser.h" +#include "urlopen.h" #include #include @@ -286,6 +287,14 @@ PlaylistWidget::addButtons (void) Skin::PLS_LST_OPN_1); } +void +PlaylistWidget::menuAddUrl () +{ + XMMSHandler &client = XMMSHandler::getInstance (); + UrlOpen *tmp = new UrlOpen (this, client.xcollection ()); + tmp->show (); +} + void PlaylistWidget::diveDir (const QString &dir) { @@ -515,3 +524,5 @@ PlaylistWidget::openPlaylistChooser () PlaylistChooser *tmp = new PlaylistChooser (this, client.xcollection ()); tmp->show (); } + + diff --git a/src/playlist/playlistwidget.h b/src/playlist/playlistwidget.h index f2f0206..6ee036f 100644 --- a/src/playlist/playlistwidget.h +++ b/src/playlist/playlistwidget.h @@ -82,7 +82,7 @@ class PlaylistWidget : public QWidget { public slots: void setPixmaps (Skin *skin); - void menuAddUrl () {} + void menuAddUrl (); void menuAddDir (); void menuAddFile (); diff --git a/src/src.pro b/src/src.pro index 8605324..3715a10 100644 --- a/src/src.pro +++ b/src/src.pro @@ -8,6 +8,7 @@ PRE_TARGETDEPS = $$COMPONENTS MOC_DIR = .moc OBJECTS_DIR = .obj +UI_DIR = .ui include(src.pri)