added dialog to add urls
This commit is contained in:
parent
4c7317f71d
commit
e1e809d8fb
9 changed files with 219 additions and 4 deletions
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
XCollection::XCollection (XClient * client) : QObject ( client)
|
XCollection::XCollection (XClient * client) : QObject ( client)
|
||||||
{
|
{
|
||||||
|
@ -162,3 +163,21 @@ XCollection::addIdlist (QString name) {
|
||||||
|
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
class QString;
|
class QString;
|
||||||
class QStringList;
|
class QStringList;
|
||||||
|
class QUrl;
|
||||||
|
|
||||||
class XCollection : public QObject
|
class XCollection : public QObject
|
||||||
{
|
{
|
||||||
|
@ -35,6 +36,7 @@ class XCollection : public QObject
|
||||||
bool setActivePlaylist (QString name);
|
bool setActivePlaylist (QString name);
|
||||||
QString activePlaylist () {return m_activePlaylist;}
|
QString activePlaylist () {return m_activePlaylist;}
|
||||||
bool addIdlist (QString name);
|
bool addIdlist (QString name);
|
||||||
|
bool playlistAddUrl (QUrl url, QString plsname = "");
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void collectionModified (QString collection, QString ns, int type,
|
void collectionModified (QString collection, QString ns, int type,
|
||||||
|
|
|
@ -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
|
INCLUDEPATH += $$PWD
|
||||||
DEPENDPATH += $$PWD
|
DEPENDPATH += $$PWD
|
||||||
|
|
45
src/dialogs/urlopen.cpp
Normal file
45
src/dialogs/urlopen.cpp
Normal 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
41
src/dialogs/urlopen.h
Normal 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
93
src/dialogs/urlopen.ui
Normal 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>
|
|
@ -27,6 +27,7 @@
|
||||||
#include "playlistmenu.h"
|
#include "playlistmenu.h"
|
||||||
#include "FileDialog.h"
|
#include "FileDialog.h"
|
||||||
#include "playlistchooser.h"
|
#include "playlistchooser.h"
|
||||||
|
#include "urlopen.h"
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
|
@ -286,6 +287,14 @@ PlaylistWidget::addButtons (void)
|
||||||
Skin::PLS_LST_OPN_1);
|
Skin::PLS_LST_OPN_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWidget::menuAddUrl ()
|
||||||
|
{
|
||||||
|
XMMSHandler &client = XMMSHandler::getInstance ();
|
||||||
|
UrlOpen *tmp = new UrlOpen (this, client.xcollection ());
|
||||||
|
tmp->show ();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistWidget::diveDir (const QString &dir)
|
PlaylistWidget::diveDir (const QString &dir)
|
||||||
{
|
{
|
||||||
|
@ -515,3 +524,5 @@ PlaylistWidget::openPlaylistChooser ()
|
||||||
PlaylistChooser *tmp = new PlaylistChooser (this, client.xcollection ());
|
PlaylistChooser *tmp = new PlaylistChooser (this, client.xcollection ());
|
||||||
tmp->show ();
|
tmp->show ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ class PlaylistWidget : public QWidget {
|
||||||
public slots:
|
public slots:
|
||||||
void setPixmaps (Skin *skin);
|
void setPixmaps (Skin *skin);
|
||||||
|
|
||||||
void menuAddUrl () {}
|
void menuAddUrl ();
|
||||||
void menuAddDir ();
|
void menuAddDir ();
|
||||||
void menuAddFile ();
|
void menuAddFile ();
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ PRE_TARGETDEPS = $$COMPONENTS
|
||||||
|
|
||||||
MOC_DIR = .moc
|
MOC_DIR = .moc
|
||||||
OBJECTS_DIR = .obj
|
OBJECTS_DIR = .obj
|
||||||
|
UI_DIR = .ui
|
||||||
|
|
||||||
include(src.pri)
|
include(src.pri)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue