added dialog to add urls

This commit is contained in:
Thomas Frauendorfer 2008-02-10 10:35:57 +01:00
parent 4c7317f71d
commit e1e809d8fb
9 changed files with 219 additions and 4 deletions

View file

@ -17,6 +17,7 @@
#include <QHash>
#include <QString>
#include <QUrl>
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;
}

View file

@ -21,6 +21,7 @@
#include <QObject>
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,

View file

@ -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

45
src/dialogs/urlopen.cpp Normal file
View file

@ -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 <QUrl>
#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 ();
}
}
}

41
src/dialogs/urlopen.h Normal file
View file

@ -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 <QDialog>
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

93
src/dialogs/urlopen.ui Normal file
View file

@ -0,0 +1,93 @@
<ui version="4.0" >
<class>UrlOpen</class>
<widget class="QDialog" name="UrlOpen" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>328</width>
<height>81</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle" >
<string>Open Url</string>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QLineEdit" name="urlEdit" />
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="openButton" >
<property name="text" >
<string>Open</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="closeButton" >
<property name="text" >
<string>Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>urlEdit</sender>
<signal>returnPressed()</signal>
<receiver>openButton</receiver>
<slot>click()</slot>
<hints>
<hint type="sourcelabel" >
<x>203</x>
<y>25</y>
</hint>
<hint type="destinationlabel" >
<x>207</x>
<y>53</y>
</hint>
</hints>
</connection>
<connection>
<sender>closeButton</sender>
<signal>clicked()</signal>
<receiver>UrlOpen</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel" >
<x>261</x>
<y>60</y>
</hint>
<hint type="destinationlabel" >
<x>56</x>
<y>57</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -27,6 +27,7 @@
#include "playlistmenu.h"
#include "FileDialog.h"
#include "playlistchooser.h"
#include "urlopen.h"
#include <QMouseEvent>
#include <QPaintEvent>
@ -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 ();
}

View file

@ -82,7 +82,7 @@ class PlaylistWidget : public QWidget {
public slots:
void setPixmaps (Skin *skin);
void menuAddUrl () {}
void menuAddUrl ();
void menuAddDir ();
void menuAddFile ();

View file

@ -8,6 +8,7 @@ PRE_TARGETDEPS = $$COMPONENTS
MOC_DIR = .moc
OBJECTS_DIR = .obj
UI_DIR = .ui
include(src.pri)