mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 09:34:53 +02:00
Add a new "Create Playlist" dialog that is shown when the user presses New Playlist.
This lets the user select between a normal playlist and an automatic playlist. Thanks for Christopher Reichert for the patch!
This commit is contained in:
@@ -161,6 +161,7 @@ set( libSources
|
||||
utils/xspfgenerator.cpp
|
||||
|
||||
widgets/newplaylistwidget.cpp
|
||||
widgets/playlisttypeselectordlg.cpp
|
||||
widgets/welcomewidget.cpp
|
||||
widgets/welcomeplaylistmodel.cpp
|
||||
widgets/overlaywidget.cpp
|
||||
@@ -324,6 +325,7 @@ set( libHeaders
|
||||
utils/xspfgenerator.h
|
||||
|
||||
widgets/newplaylistwidget.h
|
||||
widgets/playlisttypeselectordlg.h
|
||||
widgets/welcomewidget.h
|
||||
widgets/welcomeplaylistmodel.h
|
||||
widgets/overlaywidget.h
|
||||
@@ -339,6 +341,7 @@ set( libHeaders_NoMOC
|
||||
playlist/dynamic/GeneratorInterface.h
|
||||
)
|
||||
set( libUI ${libUI}
|
||||
widgets/playlisttypeselectordlg.ui
|
||||
widgets/newplaylistwidget.ui
|
||||
widgets/welcomewidget.ui
|
||||
widgets/infowidgets/sourceinfowidget.ui
|
||||
|
@@ -10,6 +10,9 @@
|
||||
<height>460</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::TabFocus</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
@@ -31,6 +34,9 @@
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
88
src/libtomahawk/widgets/playlisttypeselectordlg.cpp
Normal file
88
src/libtomahawk/widgets/playlisttypeselectordlg.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "widgets/newplaylistwidget.h"
|
||||
#include "viewmanager.h"
|
||||
#include "viewpage.h"
|
||||
#include "sourcelist.h"
|
||||
|
||||
#include "playlisttypeselectordlg.h"
|
||||
#include "ui_playlisttypeselectordlg.h"
|
||||
|
||||
|
||||
PlaylistTypeSelectorDlg::PlaylistTypeSelectorDlg( QWidget* parent, Qt::WindowFlags f )
|
||||
: QDialog( parent, f )
|
||||
, ui( new Ui::PlaylistTypeSelectorDlg )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
// ui->
|
||||
ui->horizontalLayout_2->setContentsMargins( 4, 4, 4, 4 );
|
||||
|
||||
setSizeGripEnabled( false );
|
||||
setMinimumSize( size() );
|
||||
setMaximumSize( size() ); // to remove the resize grip on osx this is the only way
|
||||
#endif
|
||||
|
||||
m_isAutoPlaylist = false;
|
||||
m_playlistName = "";
|
||||
|
||||
connect( ui->manualPlaylistButton, SIGNAL( clicked() ),
|
||||
this, SLOT( createNormalPlaylist() ));
|
||||
connect( ui->autoPlaylistButton, SIGNAL( clicked() ),
|
||||
this, SLOT( createAutomaticPlaylist() ));
|
||||
connect( ui->autoPlaylistNameLine, SIGNAL( textChanged( const QString& )),
|
||||
this, SLOT( enableAutoPlaylistButton( const QString& )));
|
||||
}
|
||||
|
||||
PlaylistTypeSelectorDlg::~PlaylistTypeSelectorDlg()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistTypeSelectorDlg::createNormalPlaylist()
|
||||
{
|
||||
m_isAutoPlaylist = false;
|
||||
done( QDialog::Accepted ); // return code is used to vaidate we did not exit out of the Dialog
|
||||
}
|
||||
|
||||
void PlaylistTypeSelectorDlg::createAutomaticPlaylist() { m_isAutoPlaylist = true;
|
||||
m_playlistName = ui->autoPlaylistNameLine->text();
|
||||
done( QDialog::Accepted ); // return code is used to vaidate we did not exit out of the Dialog successfully
|
||||
}
|
||||
|
||||
QString
|
||||
PlaylistTypeSelectorDlg::playlistName() const
|
||||
{
|
||||
return m_playlistName;
|
||||
}
|
||||
|
||||
bool
|
||||
PlaylistTypeSelectorDlg::playlistTypeIsAuto() const
|
||||
{
|
||||
return m_isAutoPlaylist;
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistTypeSelectorDlg::enableAutoPlaylistButton( const QString &text )
|
||||
{
|
||||
ui->autoPlaylistButton->setEnabled( !text.isEmpty() );
|
||||
}
|
||||
|
55
src/libtomahawk/widgets/playlisttypeselectordlg.h
Normal file
55
src/libtomahawk/widgets/playlisttypeselectordlg.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PLAYLISTTYPESELECTORDLG_H
|
||||
#define PLAYLISTTYPESELECTORDLG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class PlaylistTypeSelectorDlg;
|
||||
}
|
||||
|
||||
class DLLEXPORT PlaylistTypeSelectorDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PlaylistTypeSelectorDlg( QWidget* parent = 0, Qt::WindowFlags = 0 );
|
||||
~PlaylistTypeSelectorDlg();
|
||||
bool playlistTypeIsNormal() const;
|
||||
bool playlistTypeIsAuto() const;
|
||||
QString playlistName() const;
|
||||
|
||||
private slots:
|
||||
void createNormalPlaylist();
|
||||
void createAutomaticPlaylist();
|
||||
void enableAutoPlaylistButton( const QString& );
|
||||
|
||||
private:
|
||||
bool m_isAutoPlaylist; // if not an auto playlist then its a normal playlist
|
||||
|
||||
Ui::PlaylistTypeSelectorDlg *ui;
|
||||
QString m_playlistName;
|
||||
|
||||
};
|
||||
|
||||
#endif // PlaylistTypeSelectorDlg_H
|
184
src/libtomahawk/widgets/playlisttypeselectordlg.ui
Normal file
184
src/libtomahawk/widgets/playlisttypeselectordlg.ui
Normal file
@@ -0,0 +1,184 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PlaylistTypeSelectorDlg</class>
|
||||
<widget class="QDialog" name="PlaylistTypeSelectorDlg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>554</width>
|
||||
<height>169</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>482</width>
|
||||
<height>145</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>10000</width>
|
||||
<height>10000</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>New Playlist</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,1,0">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>221</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Just a regular old playlist... Give it a name, drag in some tracks, and go!</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="manualPlaylistButton">
|
||||
<property name="text">
|
||||
<string>Create Manual Playlist</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't know exactly what you want? Give Tomahawk a few pointers and let it build a playlist for you!</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="autoPlaylistNameLine">
|
||||
<property name="placeholderText">
|
||||
<string>New Playlist...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="autoPlaylistButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create Automatic Playlist</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@@ -19,6 +19,7 @@
|
||||
#include "tomahawkapp.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "widgets/newplaylistwidget.h"
|
||||
#include "widgets/playlisttypeselectordlg.h"
|
||||
#include "viewmanager.h"
|
||||
#include "viewpage.h"
|
||||
#include "sourcelist.h"
|
||||
@@ -59,13 +60,28 @@ CategoryAddItem::activate()
|
||||
{
|
||||
switch( m_categoryType )
|
||||
{
|
||||
case SourcesModel::PlaylistsCategory:
|
||||
// only show if none is shown yet
|
||||
if( !ViewManager::instance()->isNewPlaylistPageVisible() ) {
|
||||
ViewPage* p = ViewManager::instance()->show( new NewPlaylistWidget() );
|
||||
model()->linkSourceItemToPage( this, p );
|
||||
case SourcesModel::PlaylistsCategory: {
|
||||
|
||||
PlaylistTypeSelectorDlg playlistSelectorDlg( TomahawkApp::instance()->mainWindow() );
|
||||
int successfulReturn = playlistSelectorDlg.exec();
|
||||
|
||||
if ( !playlistSelectorDlg.playlistTypeIsAuto() && successfulReturn ) {
|
||||
|
||||
// only show if none is shown yet
|
||||
if( !ViewManager::instance()->isNewPlaylistPageVisible() ) {
|
||||
//fix this namespace resolution problem, was not there before
|
||||
Tomahawk::ViewPage* p = ViewManager::instance()->show( new NewPlaylistWidget() );
|
||||
model()->linkSourceItemToPage( this, p );
|
||||
}
|
||||
|
||||
} else if ( playlistSelectorDlg.playlistTypeIsAuto() && successfulReturn ) {
|
||||
// create Auto Playlist
|
||||
QString playlistName = playlistSelectorDlg.playlistName();
|
||||
APP->mainWindow()->createAutomaticPlaylist( playlistName );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case SourcesModel::StationsCategory:
|
||||
APP->mainWindow()->createStation();
|
||||
break;
|
||||
@@ -217,5 +233,6 @@ CategoryItem::activate()
|
||||
{
|
||||
if( m_category == SourcesModel::StationsCategory ) {
|
||||
// TODO activate stations page
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@
|
||||
#include "utils/widgetdragfilter.h"
|
||||
#include "utils/xspfloader.h"
|
||||
#include "widgets/newplaylistwidget.h"
|
||||
#include "widgets/playlisttypeselectordlg.h"
|
||||
|
||||
#include "audiocontrols.h"
|
||||
#include "settingsdialog.h"
|
||||
@@ -274,7 +275,6 @@ TomahawkWindow::setupSignals()
|
||||
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( updateCollectionManually() ) );
|
||||
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
|
||||
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
|
||||
connect( ui->actionCreateAutomaticPlaylist, SIGNAL( triggered() ), SLOT( createAutomaticPlaylist() ));
|
||||
connect( ui->actionCreate_New_Station, SIGNAL( triggered() ), SLOT( createStation() ));
|
||||
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
|
||||
connect( ui->actionExit, SIGNAL( triggered() ), qApp, SLOT( quit() ) );
|
||||
@@ -444,11 +444,11 @@ TomahawkWindow::loadSpiff()
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::createAutomaticPlaylist()
|
||||
TomahawkWindow::createAutomaticPlaylist( QString playlistName )
|
||||
{
|
||||
bool ok;
|
||||
QString name = QInputDialog::getText( this, tr( "Create New Automatic Playlist" ), tr( "Name:" ), QLineEdit::Normal, tr( "New Automatic Playlist" ), &ok );
|
||||
if ( !ok || name.isEmpty() )
|
||||
QString name = playlistName;
|
||||
|
||||
if ( name.isEmpty() )
|
||||
return;
|
||||
|
||||
source_ptr author = SourceList::instance()->getLocal();
|
||||
@@ -484,7 +484,22 @@ TomahawkWindow::createStation()
|
||||
void
|
||||
TomahawkWindow::createPlaylist()
|
||||
{
|
||||
ViewManager::instance()->show( new NewPlaylistWidget() );
|
||||
PlaylistTypeSelectorDlg playlistSelectorDlg;
|
||||
int successfulReturn = playlistSelectorDlg.exec();
|
||||
|
||||
qDebug() << "\n\nSTAT == " << successfulReturn;
|
||||
if ( !playlistSelectorDlg.playlistTypeIsAuto() && successfulReturn ) {
|
||||
|
||||
// only show if none is shown yet
|
||||
if( !ViewManager::instance()->isNewPlaylistPageVisible() ) {
|
||||
ViewManager::instance()->show( new NewPlaylistWidget() );
|
||||
}
|
||||
|
||||
} else if ( playlistSelectorDlg.playlistTypeIsAuto() && successfulReturn ) {
|
||||
// create Auto Playlist
|
||||
QString playlistName = playlistSelectorDlg.playlistName();
|
||||
APP->mainWindow()->createAutomaticPlaylist( playlistName );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -61,7 +61,7 @@ protected:
|
||||
void hideEvent( QHideEvent* e );
|
||||
|
||||
public slots:
|
||||
void createAutomaticPlaylist();
|
||||
void createAutomaticPlaylist( QString );
|
||||
void createStation();
|
||||
void createPlaylist();
|
||||
void loadSpiff();
|
||||
|
@@ -35,7 +35,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1000</width>
|
||||
<height>22</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuSettings">
|
||||
@@ -55,16 +55,6 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuPlaylist">
|
||||
<property name="title">
|
||||
<string>&Playlist</string>
|
||||
</property>
|
||||
<addaction name="actionCreatePlaylist"/>
|
||||
<addaction name="actionCreateAutomaticPlaylist"/>
|
||||
<addaction name="actionCreate_New_Station"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionLoadXSPF"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuNetwork">
|
||||
<property name="title">
|
||||
<string>&Network</string>
|
||||
@@ -86,6 +76,15 @@
|
||||
<addaction name="actionDiagnostics"/>
|
||||
<addaction name="actionAboutTomahawk"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuPlaylist">
|
||||
<property name="title">
|
||||
<string>&Playlist</string>
|
||||
</property>
|
||||
<addaction name="actionCreatePlaylist"/>
|
||||
<addaction name="actionCreate_New_Station"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionLoadXSPF"/>
|
||||
</widget>
|
||||
<addaction name="menuApp"/>
|
||||
<addaction name="menuPlaylist"/>
|
||||
<addaction name="menuNetwork"/>
|
||||
|
Reference in New Issue
Block a user