1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-23 12:21:28 +02:00

Compare commits

..

11 Commits

Author SHA1 Message Date
Michael Zanetti
a78a25baa6 remove unused old code 2011-09-24 15:26:40 +02:00
Michael Zanetti
375ffd1445 speedup animation a bit to match the other dropmenu's duration 2011-09-24 15:26:15 +02:00
Michael Zanetti
c3d223d8cb completed dropmenu in audio controls area 2011-09-24 15:20:44 +02:00
Michael Zanetti
b2f3dedaff more work the dropmenu for the audiocontrols 2011-09-04 20:56:10 +02:00
Christian Muehlhaeuser
a3ae74dc10 * Some more cleanups. 2011-09-04 20:56:10 +02:00
Christian Muehlhaeuser
4dfb989676 * Don't react to hover events unless TrackView is in Detailed mode. 2011-09-04 20:56:10 +02:00
Christian Muehlhaeuser
e0d1289a16 * Resize ContextPage's columns. 2011-09-04 20:56:10 +02:00
Christian Muehlhaeuser
cc5ba35a08 * Add forgotten ui file. 2011-09-04 20:56:10 +02:00
Christian Muehlhaeuser
e0e79c09a4 * Removed ugly queue button for good. 2011-09-04 20:56:10 +02:00
Christian Muehlhaeuser
03f726f46c * Added initial ContextView. Yikes. 2011-09-04 20:56:10 +02:00
Michael Zanetti
c0edc3a989 initial try on a dragndrop menu for audiocontrols 2011-09-04 01:54:13 +02:00
100 changed files with 2062 additions and 2660 deletions

View File

@@ -24,8 +24,6 @@ SET( TOMAHAWK_VERSION_PATCH 99 )
# build options
option(BUILD_GUI "Build Tomahawk with GUI" ON)
option(BUILD_RELEASE "Generate TOMAHAWK_VERSION without GIT info" OFF)
option(BUILD_GUI_QML"Build Tomahawk with QML Support" OFF)
# generate version string
@@ -73,11 +71,6 @@ ELSE()
MESSAGE( STATUS "Building Tomahawk ${TOMAHAWK_VERSION} full GUI version ***" )
LIST(APPEND NEEDED_QT4_COMPONENTS "QtGui" "QtWebkit" )
ENDIF()
IF( BUILD_GUI_QML )
MESSAGE( STATUS "Building Tomahawk QML version ***" )
LIST(APPEND NEEDED_QT4_COMPONENTS "QtDeclarative" )
ENDIF()
IF( BUILD_GUI AND UNIX AND NOT APPLE )
FIND_PACKAGE( X11 )
@@ -165,12 +158,9 @@ macro_optional_find_package(KDE4Installed)
# macro_optional_find_package(KDE4)
IF(KDE4_FOUND)
IF( CMAKE_C_FLAGS )
# KDE4 adds and removes some compiler flags that we don't like
# (only for gcc not for clang e.g.)
STRING( REPLACE "-std=iso9899:1990" "" CLEAN_C_FLAGS ${CMAKE_C_FLAGS} )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions" )
ENDIF()
#KDE4 adds and removes some compiler flags that we don't like
STRING( REPLACE "-std=iso9899:1990" "" CLEAN_C_FLAGS ${CMAKE_C_FLAGS} )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions" )
ELSE()
SET( CLEAN_C_FLAGS ${CMAKE_C_FLAGS} )
ENDIF()

View File

@@ -1,8 +1,4 @@
Version 0.3.0:
* Added Charts page, which shows various sources' top hits & artists.
* The Collection tree-views can now be filtered.
* Moved the song queue below to the left, below the sidebar.
* Added Footnotes, a contextual view that you can slide it.
* Show recently added playlists in dashboard rather than recently opened
playlists.
* Added MPRIS 2.1 support.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

View File

@@ -78,7 +78,6 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
settingslistdelegate.cpp
resolversmodel.cpp
tomahawkwindow.cpp
tomahawkdesktopwindow.cpp
)
SET( tomahawkHeaders ${tomahawkHeaders}
@@ -127,11 +126,12 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
resolversmodel.h
delegateconfigwrapper.h
tomahawkwindow.h
tomahawkdesktopwindow.h
Qocoa/qsearchfield.h
)
SET( tomahawkUI ${tomahawkUI}
tomahawkdesktopwindow.ui
tomahawkwindow.ui
diagnosticsdialog.ui
stackedsettingsdialog.ui
proxydialog.ui
@@ -177,12 +177,14 @@ ENDIF( UNIX )
IF( APPLE )
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/thirdparty/SPMediaKeyTap )
SET( tomahawkHeaders ${tomahawkHeaders} mac/tomahawkapp_mac.h mac/macshortcuthandler.h )
SET( tomahawkSources ${tomahawkSources} mac/tomahawkapp_mac.mm mac/macshortcuthandler.cpp )
SET( tomahawkHeaders ${tomahawkHeaders} mac/tomahawkapp_mac.h mac/macshortcuthandler.h )
SET( tomahawkSources ${tomahawkSources} mac/tomahawkapp_mac.mm mac/macshortcuthandler.cpp Qocoa/qsearchfield_mac.mm )
IF(HAVE_SPARKLE)
SET( tomahawkHeaders ${tomahawkHeaders} ${SPARKLE}/Headers )
ENDIF(HAVE_SPARKLE)
ELSE( APPLE )
SET( tomahawkSources ${tomahawkSources} Qocoa/qsearchfield.cpp )
ENDIF( APPLE )
IF(GLOOX_FOUND)
@@ -240,7 +242,7 @@ IF(QCA2_FOUND)
SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${QCA2_LIBRARIES} )
ENDIF(QCA2_FOUND)
SET( tomahawkLinkLibraries
TARGET_LINK_LIBRARIES( tomahawk
${LINK_LIBRARIES}
${TOMAHAWK_LIBRARIES}
${PHONON_LIBS}
@@ -253,13 +255,6 @@ SET( tomahawkLinkLibraries
${TAGLIB_LIBRARIES}
)
TARGET_LINK_LIBRARIES( tomahawk ${tomahawkLinkLibraries} )
IF( BUILD_GUI_QML )
# sic! add_subdirectory would make it harder to reuse ${final_src}
INCLUDE( active/CMakeLists.txt )
ENDIF()
IF( APPLE )
IF(HAVE_SPARKLE)
MESSAGE("Sparkle Found, installing framekwork in bundle")

View File

@@ -22,7 +22,7 @@
#include <QTreeWidget>
#include "typedefs.h"
#include "widgets/animatedsplitter.h"
#include "utils/animatedsplitter.h"
class StreamConnection;

View File

@@ -29,7 +29,7 @@ THE SOFTWARE.
#include "playlist/topbar/searchlineedit.h"
#include "utils/tomahawkutils.h"
class DLLEXPORT QSearchFieldPrivate
class QSearchFieldPrivate
{
public:
QSearchFieldPrivate(SearchLineEdit *lineEdit) : lineEdit(lineEdit) {}
@@ -51,17 +51,10 @@ QSearchField::QSearchField(QWidget *parent) : QWidget(parent)
TomahawkUtils::unmarginLayout(layout);
setContentsMargins(0, 0, 0, 0);
lineEdit->setStyleSheet( "QLineEdit { border: 1px solid gray; border-radius: 6px; }" );
#ifdef Q_OS_MAC
lineEdit->setStyleSheet( "QLineEdit { border: 1px solid gray; border-radius: 6px; margin-right: 2px; }" );
lineEdit->setContentsMargins(0, 0, 0, 0);
lineEdit->setMinimumHeight(27);
setFixedHeight(27);
#else
lineEdit->setContentsMargins(2, 2, 2, 2);
lineEdit->setMinimumHeight(27);
#endif
}
void QSearchField::setText(const QString &text)

View File

@@ -3,10 +3,8 @@
#include <QWidget>
#include "dllmacro.h"
class QSearchFieldPrivate;
class DLLEXPORT QSearchField : public QWidget
class QSearchField : public QWidget
{
Q_OBJECT
public:

View File

@@ -1,30 +0,0 @@
SET( touchmahawkSources ${final_src} )
#LIST( REMOVE_ITEM touchmahawkSources "main.cpp" )
SET( touchmahawkHeaders
active/tomahawktouchwindow.h
)
SET( touchmahawkSources
${touchmahawkSources}
active/tomahawktouchwindow.cpp
# active/main.cpp
)
qt4_wrap_cpp( touchmahawkMoc ${touchmahawkHeaders} )
SET( touchmahawkFinalSources ${touchmahawkMoc} ${touchmahawkSources} )
SET( touchmahawkLinkLibraries
kdeclarative
${tomahawkLinkLibraries}
) #${QT_QTDECLARATIVE_LIBRARY}
ADD_EXECUTABLE( active-tomahawk ${touchmahawkFinalSources} )
TARGET_LINK_LIBRARIES( active-tomahawk ${touchmahawkLinkLibraries} )
SET_TARGET_PROPERTIES( active-tomahawk PROPERTIES COMPILE_FLAGS -DTOUCHMAHAWK )
INSTALL( TARGETS active-tomahawk DESTINATION bin )

View File

@@ -1,134 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2011, Dominik Schmidt <domme@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 "active/tomahawktouchwindow.h"
#include "utils/logger.h"
#include "audio/audioengine.h"
#include "globalactionmanager.h"
#include "sourcesmodel.h"
#include "items/sourcetreeitem.h"
#include "items/collectionitem.h"
#include "viewmanager.h"
#include "libtomahawk/playlist/treeproxymodel.h"
#include <QFileSystemWatcher>
#include <QtDeclarative>
#define QMLGUI "/home/domme/dev/sources/tomahawk-qml"
TomahawkTouchWindow::TomahawkTouchWindow()
: m_view(0)
, m_currentPlaylistTreeModel(0)
{
QFileSystemWatcher* watcher = new QFileSystemWatcher;
watcher->addPath( QMLGUI );
connect( watcher, SIGNAL( directoryChanged( QString ) ), SLOT( loadQml() ));
loadQml();
setCentralWidget( m_view );
setWindowTitle("Touch-ma-hawk");
}
TomahawkTouchWindow::~TomahawkTouchWindow()
{
}
void TomahawkTouchWindow::play(const QModelIndex& index )
{
TreeModelItem* item = m_currentPlaylistTreeModel->sourceModel()->itemFromIndex( m_currentPlaylistTreeModel->mapToSource( index ) );
if ( item )
{
m_currentPlaylistTreeModel->sourceModel()->setCurrentItem( item->index );
AudioEngine::instance()->playItem( m_currentPlaylistTreeModel, item->result() );
}
}
void TomahawkTouchWindow::activateItem(const QModelIndex& index)
{
tLog() << Q_FUNC_INFO << index;
SourceTreeItem* item = qobject_cast< SourceTreeItem* >( s_sourcesModel->data( index, SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
item->activate();
CollectionItem* collectionItem = qobject_cast< CollectionItem* >( item );
if( collectionItem )
{
tLog() << "Activate collectionItem!";
Tomahawk::collection_ptr collection = collectionItem->source()->collection();
TreeModel* model = ViewManager::instance()->treeModelForCollection( collection );
TreeProxyModel* proxyModel = m_modelProxyModels.value( model );
if( !proxyModel )
{
proxyModel = new TreeProxyModel();
//m_currentPlaylistTreeModel->setDynamicSortFilter( true );
proxyModel->setSourceTreeModel( model );
proxyModel->sort(TreeModel::Name, Qt::AscendingOrder );
//m_currentPlaylistTreeModel->setShowModes( false );
//m_currentPlaylistTreeModel->setSortRole( );
}
m_currentPlaylistTreeModel = proxyModel;
emit currentTreeModelChanged();
//m_view->rootContext()->setContextProperty( "currentPlaylistTreeModel", m_currentPlaylistTreeModel );
}
}
void
TomahawkTouchWindow::loadQml()
{
tLog() << Q_FUNC_INFO;
qmlRegisterType<AudioEngine>("org.tomahawkplayer.qmlcomponents", 1, 0, "AudioEngine");
qmlRegisterType<TreeProxyModel>("org.tomahawkplayer.qmlcomponents", 1, 0, "TreeProxyModel");
if( !m_view )
{
tLog()<< Q_FUNC_INFO << "create qml view";
m_view = new QDeclarativeView;
m_view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
m_view->show();
}
tLog()<< Q_FUNC_INFO << "clear component cache";
m_view->engine()->clearComponentCache();
tLog()<< Q_FUNC_INFO << "set context property";
QDeclarativeContext* context = m_view->rootContext();
tLog()<< Q_FUNC_INFO << "make objects accessible from qml";
context->setContextProperty( "touchWindow", this );
context->setContextProperty( "audioEngine", AudioEngine::instance() );
context->setContextProperty( "globalActionManager", GlobalActionManager::instance() );
context->setContextProperty( "sourcesModel", s_sourcesModel );
// don't start in an undefined state
m_currentPlaylistTreeModel = 0;
//context->setContextProperty( "currentPlaylistTreeModel", m_currentPlaylistTreeModel );
tLog()<< Q_FUNC_INFO << "set source";
m_view->setSource( QUrl::fromLocalFile( QMLGUI "/main.qml" ) );
}

View File

@@ -1,62 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2011, Dominik Schmidt <domme@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 TOMAHAWKTOUCHWINDOW_H
#define TOMAHAWKTOUCHWINDOW_H
#include "tomahawkwindow.h"
#include <QtDeclarative>
class TomahawkTouchWindow;
class QFileSystemWatcher;
class TreeModel;
class TreeProxyModel;
class TomahawkTouchWindow : public TomahawkWindow
{
Q_OBJECT
Q_PROPERTY( TreeProxyModel* currentTreeModel READ currentTreeModel NOTIFY currentTreeModelChanged )
public:
TomahawkTouchWindow();
~TomahawkTouchWindow();
Q_INVOKABLE void play( const QModelIndex& index );
Q_INVOKABLE void activateItem( const QModelIndex& index );
signals:
void currentTreeModelChanged();
private slots:
void loadQml();
private:
TreeProxyModel* currentTreeModel() { return m_currentPlaylistTreeModel; }
QDeclarativeView* m_view;
QFileSystemWatcher* m_watcher;
TreeProxyModel* m_currentPlaylistTreeModel;
QHash< TreeModel*, TreeProxyModel* > m_modelProxyModels;
};
#endif // TOMAHAWKTOUCHWINDOW_H

View File

@@ -24,16 +24,18 @@
#include <QMouseEvent>
#include "audio/audioengine.h"
#include "viewmanager.h"
#include "playlist/playlistview.h"
#include "database/database.h"
#include "database/databasecommand_socialaction.h"
#include "widgets/imagebutton.h"
#include "album.h"
#include "utils/imagebutton.h"
#include "utils/tomahawkutils.h"
#include "utils/logger.h"
#include "album.h"
#include <globalactionmanager.h>
#include "dropjob.h"
#include "globalactionmanager.h"
#include "viewmanager.h"
using namespace Tomahawk;
@@ -45,6 +47,7 @@ AudioControls::AudioControls( QWidget* parent )
, ui( new Ui::AudioControls )
, m_repeatMode( PlaylistInterface::NoRepeat )
, m_shuffled( false )
, m_dropAreaExpanded( false )
{
ui->setupUi( this );
setAcceptDrops( true );
@@ -88,7 +91,7 @@ AudioControls::AudioControls( QWidget* parent )
ui->ownerLabel->setForegroundRole( QPalette::Dark );
ui->metaDataArea->setStyleSheet( "QWidget#metaDataArea {\nborder-width: 4px;\nborder-image: url(" RESPATH "images/now-playing-panel.png) 4 4 4 4 stretch stretch; }" );
ui->seekSlider->setEnabled( true );
ui->volumeSlider->setRange( 0, 100 );
ui->volumeSlider->setValue( AudioEngine::instance()->volume() );
@@ -97,7 +100,7 @@ AudioControls::AudioControls( QWidget* parent )
ui->seekSlider->setTimeLine( &m_sliderTimeLine );
connect( &m_sliderTimeLine, SIGNAL( frameChanged( int ) ), ui->seekSlider, SLOT( setValue( int ) ) );
connect( ui->seekSlider, SIGNAL( valueChanged( int ) ), AudioEngine::instance(), SLOT( seek( int ) ) );
connect( ui->volumeSlider, SIGNAL( valueChanged( int ) ), AudioEngine::instance(), SLOT( setVolume( int ) ) );
connect( ui->prevButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( previous() ) );
@@ -146,6 +149,46 @@ AudioControls::AudioControls( QWidget* parent )
ui->stackedLayout->setSizeConstraint( QLayout::SetFixedSize );
onPlaybackStopped(); // initial state
m_dragAnimation = new QPropertyAnimation( this, "dropAreaSize", this );
m_dragAnimation->setStartValue( 0 );
m_dragAnimation->setDuration( 300 );
m_dragAnimation->setEasingCurve( QEasingCurve::Linear );
connect( m_dragAnimation, SIGNAL( finished() ), SLOT(dragAnimationFinished()));
m_dropAreaCollapseTimer.setInterval( 300 );
m_dropAreaCollapseTimer.setSingleShot( true );
connect( &m_dropAreaCollapseTimer, SIGNAL( timeout() ), this, SLOT( collapseDropMenu() ) );
connect( ui->metaDataDropArea, SIGNAL( dropReceived( QDropEvent* ) ), this, SLOT( dropReceived( QDropEvent* ) ) );
connect( ui->metaDataDropArea, SIGNAL( mouseLeft() ), &m_dropAreaCollapseTimer, SLOT( start() ) );
DropMenuEntry *trackEntry = new DropMenuEntry( QPixmap(":/data/images/drop-song.png" ).scaledToWidth( 32, Qt::SmoothTransformation ),
"Track",
DropJob::DropFlagTrack );
ui->metaDataDropArea->addEntry( trackEntry, true );
DropMenuEntry *albumEntry = new DropMenuEntry( QPixmap(":/data/images/drop-album.png" ).scaledToWidth( 32, Qt::SmoothTransformation ),
"Album",
DropJob::DropFlagAlbum );
ui->metaDataDropArea->addEntry( albumEntry );
DropMenuEntry *artistEntry = new DropMenuEntry( QPixmap(":/data/images/drop-all-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ),
"Artist",
DropJob::DropFlagArtist );
ui->metaDataDropArea->addEntry( artistEntry );
DropMenuEntry *localEntry = new DropMenuEntry( QPixmap(":/data/images/drop-local-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ),
"Local",
DropJob::DropFlagAlbum | DropJob::DropFlagLocal );
ui->metaDataDropArea->addEntry( localEntry );
DropMenuEntry *top10Entry = new DropMenuEntry( QPixmap(":/data/images/drop-top-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ),
"Top 10",
DropJob::DropFlagArtist | DropJob::DropFlagTop10 );
ui->metaDataDropArea->addEntry( top10Entry );
}
@@ -187,7 +230,7 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
if ( result.isNull() )
return;
if ( m_currentTrack.isNull() || ( !m_currentTrack.isNull() && m_currentTrack.data()->id() != result.data()->id() ) )
onPlaybackLoading( result );
@@ -195,7 +238,7 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
if ( duration == -1 )
duration = result.data()->duration() * 1000;
ui->seekSlider->setRange( 0, duration );
ui->seekSlider->setValue( 0 );
@@ -206,7 +249,7 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
m_seekMsecs = -1;
ui->seekSlider->setVisible( true );
Tomahawk::InfoSystem::InfoCriteriaHash trackInfo;
trackInfo["artist"] = result->artist()->name();
trackInfo["album"] = result->album()->name();
@@ -372,7 +415,7 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
const int seconds = msElapsed / 1000;
ui->timeLabel->setText( TomahawkUtils::timeToString( seconds ) );
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( m_currentTrack->duration() - seconds ) );
if ( m_sliderTimeLine.currentTime() > msElapsed || m_seekMsecs != -1 )
{
m_sliderTimeLine.setPaused( true );
@@ -519,7 +562,36 @@ void
AudioControls::dragEnterEvent( QDragEnterEvent* e )
{
if ( DropJob::acceptsMimeData( e->mimeData() ) )
{
e->acceptProposedAction();
m_dropAreaCollapseTimer.stop();
DropJob::DropFlags flags = DropJob::DropFlagsNone;
if ( e->mimeData()->hasFormat( "application/tomahawk.query.list" )
|| e->mimeData()->hasFormat( "application/tomahawk.result.list" )
|| e->mimeData()->hasFormat( "application/tomahawk.result" ) )
flags = DropJob::DropFlagsAll;
if ( e->mimeData()->hasFormat( "application/tomahawk.metadata.album" ) )
flags = DropJob::DropFlagAlbum | DropJob::DropFlagArtist | DropJob::DropFlagLocal | DropJob::DropFlagTop10;
if ( e->mimeData()->hasFormat( "application/tomahawk.metadata.artist" ) )
flags = DropJob::DropFlagArtist | DropJob::DropFlagLocal | DropJob::DropFlagTop10;
ui->metaDataDropArea->setFilter( flags );
if( !m_dropAreaExpanded )
{
m_dragAnimation->stop();
m_dragAnimation->setDirection( QAbstractAnimation::Forward );
m_dragAnimation->setStartValue( dropAreaSize() );
m_dragAnimation->setEndValue( ui->metaDataArea->height() );
m_dragAnimation->start();
m_dropAreaExpanded = true;
}
}
}
@@ -531,6 +603,32 @@ AudioControls::dragMoveEvent( QDragMoveEvent* /* e */ )
}
void
AudioControls::dragLeaveEvent( QDragLeaveEvent * )
{
qDebug() << "******************************** dragLeaveEvent" << ui->metaDataDropArea->hovered();
if( !ui->metaDataDropArea->hovered() )
m_dropAreaCollapseTimer.start();
}
void
AudioControls::collapseDropMenu()
{
// Check if the menu is hovered now...
if( ui->metaDataDropArea->hovered() )
return;
m_dropAreaExpanded = false;
m_dragAnimation->stop();
// m_dragAnimation->setDirection( QAbstractAnimation::Backward );
m_dragAnimation->setStartValue( dropAreaSize() );
m_dragAnimation->setEndValue( 0 );
m_dragAnimation->start();
}
void
AudioControls::dropEvent( QDropEvent* e )
{
@@ -539,8 +637,11 @@ AudioControls::dropEvent( QDropEvent* e )
{
DropJob *dj = new DropJob();
connect( dj, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ), this, SLOT( droppedTracks( QList<Tomahawk::query_ptr> ) ) );
dj->setDropFlags( ui->metaDataDropArea->activeEntry()->dropFlags() );
dj->tracksFromMimeData( e->mimeData() );
QTimer::singleShot( 0, this, SLOT( collapseDropMenu() ) );
e->accept();
}
}
@@ -593,3 +694,28 @@ AudioControls::onLoveButtonClicked( bool checked )
}
}
void
AudioControls::dragAnimationFinished()
{
}
int
AudioControls::dropAreaSize()
{
return ui->metaDataDropArea->maximumHeight();
}
void
AudioControls::setDropAreaSize( int size )
{
ui->metaDataDropArea->setMaximumHeight( size );
ui->metaDataInfoArea->setMaximumHeight( ui->metaDataArea->height() - size );
}
void
AudioControls::dropReceived( QDropEvent *event )
{
dropEvent( event );
}

View File

@@ -21,10 +21,13 @@
#include <QWidget>
#include <QTimeLine>
#include <QPropertyAnimation>
#include <QTimer>
#include "result.h"
#include "playlistinterface.h"
#include "infosystem/infosystem.h"
#include "utils/dropmenu.h"
class QDropEvent;
class QDragEnterEvent;
@@ -37,6 +40,7 @@ namespace Ui
class AudioControls : public QWidget
{
Q_OBJECT
Q_PROPERTY( int dropAreaSize READ dropAreaSize WRITE setDropAreaSize )
public:
AudioControls( QWidget* parent = 0 );
@@ -54,8 +58,12 @@ protected:
void changeEvent( QEvent* e );
void dragEnterEvent ( QDragEnterEvent* );
void dragMoveEvent ( QDragMoveEvent* );
void dragLeaveEvent( QDragLeaveEvent * );
void dropEvent ( QDropEvent* );
int dropAreaSize();
void setDropAreaSize( int size );
private slots:
void onPlaybackStarted( const Tomahawk::result_ptr& result );
void onPlaybackLoading( const Tomahawk::result_ptr& result );
@@ -82,6 +90,10 @@ private slots:
void socialActionsLoaded();
void collapseDropMenu();
void dragAnimationFinished();
void dropReceived( QDropEvent *event );
private:
Ui::AudioControls *ui;
@@ -93,6 +105,10 @@ private:
QTimeLine m_sliderTimeLine;
qint64 m_seekMsecs;
QPropertyAnimation *m_dragAnimation;
bool m_dropAreaExpanded;
QTimer m_dropAreaCollapseTimer;
};
#endif // AUDIOCONTROLS_H

View File

@@ -84,14 +84,14 @@
<property name="spacing">
<number>0</number>
</property>
<item>
<item row="0" column="0">
<widget class="ImageButton" name="playPauseButton">
<property name="text">
<string>Play</string>
</property>
</widget>
</item>
<item>
<item row="0" column="0">
<widget class="ImageButton" name="pauseButton">
<property name="text">
<string>Pause</string>
@@ -125,248 +125,269 @@
</item>
<item>
<widget class="QWidget" name="metaDataArea" native="true">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>74</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="coverImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>58</width>
<height>58</height>
</size>
</property>
<widget class="DropMenu" name="metaDataDropArea" native="true">
<property name="maximumSize">
<size>
<width>58</width>
<height>58</height>
<width>16777215</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>4</number>
<widget class="QWidget" name="metaDataInfoArea" native="true">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>74</height>
</size>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,0,0">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="trackLabelLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QueryLabel" name="artistTrackLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>16</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Artist</string>
</property>
</widget>
</item>
<item>
<widget class="QueryLabel" name="albumLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>16</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Album</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>4</width>
<height>8</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="ImageButton" name="loveButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>love</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="ownerLabel">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Owner</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>4</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="timeLabel">
<property name="text">
<string>Time</string>
</property>
</widget>
</item>
<item>
<widget class="SeekSlider" name="seekSlider">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="timeLeftLabel">
<property name="text">
<string>Time Left</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="coverImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>58</width>
<height>58</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>58</width>
<height>58</height>
</size>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,0,0,0">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="trackLabelLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QueryLabel" name="artistTrackLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>16</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Artist</string>
</property>
</widget>
</item>
<item>
<widget class="QueryLabel" name="albumLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>16</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Album</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>4</width>
<height>8</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="ImageButton" name="loveButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>love</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="ownerLabel">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Owner</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>4</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="timeLabel">
<property name="text">
<string>Time</string>
</property>
</widget>
</item>
<item>
<widget class="SeekSlider" name="seekSlider">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="timeLeftLabel">
<property name="text">
<string>Time Left</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
<zorder>metaDataInfoArea</zorder>
<zorder>metaDataDropArea</zorder>
</widget>
</item>
<item>
@@ -537,12 +558,18 @@
<customwidget>
<class>ImageButton</class>
<extends>QPushButton</extends>
<header>widgets/imagebutton.h</header>
<header>utils/imagebutton.h</header>
</customwidget>
<customwidget>
<class>QueryLabel</class>
<extends>QLabel</extends>
<header>widgets/querylabel.h</header>
<header>utils/querylabel.h</header>
</customwidget>
<customwidget>
<class>DropMenu</class>
<extends>QWidget</extends>
<header>utils/dropmenu.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>

View File

@@ -95,8 +95,6 @@ set( libSources
database/databasecommand_genericselect.cpp
database/database.cpp
infobar/infobar.cpp
infosystem/infosystemcache.cpp
infosystem/infosystem.cpp
infosystem/infosystemworker.cpp
@@ -131,7 +129,6 @@ set( libSources
playlist/albumview.cpp
playlist/artistview.cpp
playlist/customplaylistview.cpp
playlist/ViewHeader.cpp
playlist/topbar/topbar.cpp
playlist/topbar/clearbutton.cpp
@@ -139,6 +136,8 @@ set( libSources
playlist/topbar/lineedit.cpp
playlist/topbar/searchbutton.cpp
playlist/infobar/infobar.cpp
playlist/dynamic/DynamicPlaylist.cpp
playlist/dynamic/DynamicControl.cpp
playlist/dynamic/GeneratorFactory.cpp
@@ -170,9 +169,13 @@ set( libSources
network/controlconnection.cpp
utils/tomahawkutils.cpp
utils/querylabel.cpp
utils/elidedlabel.cpp
utils/imagebutton.cpp
utils/logger.cpp
utils/proxystyle.cpp
utils/widgetdragfilter.cpp
utils/animatedsplitter.cpp
utils/xspfloader.cpp
utils/xspfgenerator.cpp
utils/jspfloader.cpp
@@ -180,11 +183,8 @@ set( libSources
utils/rdioparser.cpp
utils/shortenedlinkparser.cpp
utils/stylehelper.cpp
utils/dropmenu.cpp
widgets/querylabel.cpp
widgets/imagebutton.cpp
widgets/animatedsplitter.cpp
widgets/elidedlabel.cpp
widgets/newplaylistwidget.cpp
widgets/searchwidget.cpp
widgets/SeekSlider.cpp
@@ -207,10 +207,10 @@ set( libSources
widgets/headerbreadcrumb.cpp
widgets/siblingcrumbbutton.cpp
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.cpp
thirdparty/kdsingleapplicationguard/kdsharedmemorylocker.cpp
thirdparty/kdsingleapplicationguard/kdtoolsglobal.cpp
thirdparty/kdsingleapplicationguard/kdlockedsharedmemorypointer.cpp
kdsingleapplicationguard/kdsingleapplicationguard.cpp
kdsingleapplicationguard/kdsharedmemorylocker.cpp
kdsingleapplicationguard/kdtoolsglobal.cpp
kdsingleapplicationguard/kdlockedsharedmemorypointer.cpp
)
set( libHeaders
@@ -296,8 +296,6 @@ set( libHeaders
database/databasecommand_loadsocialactions.h
database/databasecommand_genericselect.h
infobar/infobar.h
infosystem/infosystem.h
infosystem/infosystemworker.h
infosystem/infosystemcache.h
@@ -342,7 +340,6 @@ set( libHeaders
playlist/albumview.h
playlist/artistview.h
playlist/customplaylistview.h
playlist/ViewHeader.h
playlist/topbar/topbar.h
playlist/topbar/clearbutton.h
@@ -351,6 +348,8 @@ set( libHeaders
playlist/topbar/lineedit_p.h
playlist/topbar/searchbutton.h
playlist/infobar/infobar.h
playlist/dynamic/DynamicPlaylist.h
playlist/dynamic/DynamicControl.h
playlist/dynamic/GeneratorInterface.h
@@ -370,7 +369,12 @@ set( libHeaders
playlist/dynamic/database/DatabaseControl.h
playlist/dynamic/database/DatabaseGenerator.h
utils/querylabel.h
utils/elidedlabel.h
utils/animatedcounterlabel.h
utils/imagebutton.h
utils/widgetdragfilter.h
utils/animatedsplitter.h
utils/xspfloader.h
utils/xspfgenerator.h
utils/jspfloader.h
@@ -378,12 +382,8 @@ set( libHeaders
utils/rdioparser.h
utils/shortenedlinkparser.h
utils/stylehelper.h
utils/dropmenu.h
widgets/querylabel.h
widgets/animatedcounterlabel.h
widgets/imagebutton.h
widgets/animatedsplitter.h
widgets/elidedlabel.h
widgets/newplaylistwidget.h
widgets/searchwidget.h
widgets/SeekSlider.h
@@ -407,8 +407,7 @@ set( libHeaders
widgets/headerbreadcrumb.h
widgets/siblingcrumbbutton.h
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.h
thirdparty/Qocoa/qsearchfield.h
kdsingleapplicationguard/kdsingleapplicationguard.h
)
set( libHeaders_NoMOC
@@ -433,9 +432,9 @@ set( libUI ${libUI}
widgets/infowidgets/ArtistInfoWidget.ui
widgets/infowidgets/AlbumInfoWidget.ui
playlist/topbar/topbar.ui
playlist/infobar/infobar.ui
playlist/queueview.ui
context/ContextWidget.ui
infobar/infobar.ui
)
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.. ..
@@ -500,8 +499,7 @@ IF( APPLE )
SET( libSources ${libSources}
infosystem/infoplugins/mac/adium.mm
infosystem/infoplugins/mac/adiumplugin.cpp
utils/tomahawkutils_mac.mm
thirdparty/Qocoa/qsearchfield_mac.mm )
utils/tomahawkutils_mac.mm )
SET( libHeaders ${libHeaders}
infosystem/infoplugins/mac/adium.h
@@ -517,8 +515,6 @@ IF( APPLE )
/System/Library/Frameworks/AppKit.framework
)
ELSE( APPLE )
SET( libSources ${libSources} thirdparty/Qocoa/qsearchfield.cpp )
ENDIF( APPLE )
IF(LIBLASTFM_FOUND)

View File

@@ -74,12 +74,6 @@ AudioEngine::AudioEngine()
connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), this, SLOT( onVolumeChanged( qreal ) ) );
onVolumeChanged( m_audioOutput->volume() );
connect( this, SIGNAL(started(Tomahawk::result_ptr)), SIGNAL(currentTrackChanged()));
connect( this, SIGNAL(stopped()), SIGNAL(currentTrackChanged()));
#ifdef Q_OS_MAC
// On mac, phonon volume is independent from system volume, so the onVolumeChanged call above just sets our volume to 100%.
// Since it's indendent, we'll set it to 75% since that's nicer

View File

@@ -29,8 +29,6 @@
#include "infosystem/infosystem.h"
#include "result.h"
#include "album.h"
#include "artist.h"
#include "typedefs.h"
#include "dllmacro.h"
@@ -44,12 +42,7 @@ namespace Tomahawk
class DLLEXPORT AudioEngine : public QObject
{
Q_OBJECT
Q_ENUMS( AudioState )
Q_PROPERTY(AudioState audioState READ state NOTIFY stateChanged)
Q_PROPERTY(QString currentArtist READ currentArtist NOTIFY currentTrackChanged)
Q_PROPERTY(QString currentAlbum READ currentAlbum NOTIFY currentTrackChanged)
Q_PROPERTY(QString currentTitle READ currentTitle NOTIFY currentTrackChanged)
Q_OBJECT
public:
enum AudioErrorCode { StreamReadError, AudioDeviceError, DecodeError };
@@ -109,13 +102,7 @@ public slots:
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString caller );
const QString currentArtist() const { return !m_currentTrack.isNull() ? m_currentTrack->artist()->name() : QString(); }
const QString currentAlbum() const { return !m_currentTrack.isNull() ? currentTrack()->album()->name() : QString(); }
const QString currentTitle() const { return !m_currentTrack.isNull() ? currentTrack()->track() : QString(); }
signals:
void currentTrackChanged();
void loading( const Tomahawk::result_ptr& track );
void started( const Tomahawk::result_ptr& track );
void finished( const Tomahawk::result_ptr& track );

View File

@@ -54,13 +54,11 @@ ContextProxyPage::setPage( Tomahawk::ContextPage* page )
{
m_page = page;
#ifdef Q_OS_LINUX //FIXME: why do we need this? maybe it's only oxygen style misbehaving?
QGraphicsWebView* testWebView = qobject_cast<QGraphicsWebView*>( page->widget() );
if ( testWebView )
{
setContentsMargins( 4, 4, 4, 4 );
}
#endif
QGraphicsLinearLayout* layout = new QGraphicsLinearLayout();
layout->setContentsMargins( 4, 20, 4, 4 );
@@ -68,6 +66,7 @@ ContextProxyPage::setPage( Tomahawk::ContextPage* page )
setLayout( layout );
page->widget()->installEventFilter( this );
page->widget()->installSceneEventFilter( this );
}

View File

@@ -21,7 +21,6 @@
#include <QSqlQuery>
#include "databaseimpl.h"
#include "utils/tomahawkutils.h"
#include "utils/logger.h"
@@ -30,7 +29,7 @@ DatabaseCommand_AllAlbums::execForArtist( DatabaseImpl* dbi )
{
TomahawkSqlQuery query = dbi->newquery();
QList<Tomahawk::album_ptr> al;
QString orderToken, sourceToken, filterToken, tables;
QString orderToken, sourceToken;
switch ( m_sortOrder )
{
@@ -44,33 +43,17 @@ DatabaseCommand_AllAlbums::execForArtist( DatabaseImpl* dbi )
if ( !m_collection.isNull() )
sourceToken = QString( "AND file.source %1 " ).arg( m_collection->source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( m_collection->source()->id() ) );
if ( !m_filter.isEmpty() )
{
QString filtersql;
QStringList sl = m_filter.split( " ", QString::SkipEmptyParts );
foreach( QString s, sl )
{
filtersql += QString( " AND ( artist.name LIKE '%%1%' OR album.name LIKE '%%1%' OR track.name LIKE '%%1%' )" ).arg( TomahawkUtils::sqlEscape( s ) );
}
filterToken = QString( "AND artist.id = file_join.artist AND file_join.track = track.id %1" ).arg( filtersql );
tables = "artist, track, file, file_join";
}
else
tables = "file, file_join";
QString sql = QString(
"SELECT DISTINCT album.id, album.name "
"FROM %1 "
"FROM file, file_join "
"LEFT OUTER JOIN album "
"ON file_join.album = album.id "
"WHERE file.id = file_join.file "
"AND file_join.artist = %2 "
"%3 %4 %5 %6 %7"
).arg( tables )
.arg( m_artist->id() )
"AND file_join.artist = %1 "
"%2 "
"%3 %4 %5"
).arg( m_artist->id() )
.arg( sourceToken )
.arg( filterToken )
.arg( m_sortOrder > 0 ? QString( "ORDER BY %1" ).arg( orderToken ) : QString() )
.arg( m_sortDescending ? "DESC" : QString() )
.arg( m_amount > 0 ? QString( "LIMIT 0, %1" ).arg( m_amount ) : QString() );

View File

@@ -59,7 +59,6 @@ public:
void setLimit( unsigned int amount ) { m_amount = amount; }
void setSortOrder( DatabaseCommand_AllAlbums::SortOrder order ) { m_sortOrder = order; }
void setSortDescending( bool descending ) { m_sortDescending = descending; }
void setFilter( const QString& filter ) { m_filter = filter; }
signals:
void albums( const QList<Tomahawk::album_ptr>&, const QVariant& data );
@@ -72,7 +71,6 @@ private:
unsigned int m_amount;
DatabaseCommand_AllAlbums::SortOrder m_sortOrder;
bool m_sortDescending;
QString m_filter;
};
#endif // DATABASECOMMAND_ALLALBUMS_H

View File

@@ -21,7 +21,6 @@
#include <QSqlQuery>
#include "databaseimpl.h"
#include "utils/tomahawkutils.h"
#include "utils/logger.h"
@@ -30,7 +29,7 @@ DatabaseCommand_AllArtists::exec( DatabaseImpl* dbi )
{
TomahawkSqlQuery query = dbi->newquery();
QList<Tomahawk::artist_ptr> al;
QString orderToken, sourceToken, filterToken, tables;
QString orderToken, sourceToken;
switch ( m_sortOrder )
{
@@ -42,32 +41,15 @@ DatabaseCommand_AllArtists::exec( DatabaseImpl* dbi )
}
if ( !m_collection.isNull() )
sourceToken = QString( "AND file.source %1" ).arg( m_collection->source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( m_collection->source()->id() ) );
if ( !m_filter.isEmpty() )
{
QString filtersql;
QStringList sl = m_filter.split( " ", QString::SkipEmptyParts );
foreach( QString s, sl )
{
filtersql += QString( " AND ( artist.name LIKE '%%1%' OR album.name LIKE '%%1%' OR track.name LIKE '%%1%' )" ).arg( TomahawkUtils::sqlEscape( s ) );
}
filterToken = QString( "AND file_join.album = album.id AND file_join.track = track.id %1" ).arg( filtersql );
tables = "artist, track, album, file, file_join";
}
else
tables = "artist, file, file_join";
sourceToken = QString( "AND file.source %1 " ).arg( m_collection->source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( m_collection->source()->id() ) );
QString sql = QString(
"SELECT DISTINCT artist.id, artist.name "
"FROM %1 "
"FROM artist, file, file_join "
"WHERE file.id = file_join.file "
"AND file_join.artist = artist.id "
"%2 %3 %4 %5 %6"
).arg( tables )
.arg( sourceToken )
.arg( filterToken )
"%1 %2 %3 %4"
).arg( sourceToken )
.arg( m_sortOrder > 0 ? QString( "ORDER BY %1" ).arg( orderToken ) : QString() )
.arg( m_sortDescending ? "DESC" : QString() )
.arg( m_amount > 0 ? QString( "LIMIT 0, %1" ).arg( m_amount ) : QString() );
@@ -82,6 +64,7 @@ DatabaseCommand_AllArtists::exec( DatabaseImpl* dbi )
al << artist;
}
emit artists( al );
if ( al.count() )
emit artists( al );
emit done();
}

View File

@@ -54,7 +54,6 @@ public:
void setLimit( unsigned int amount ) { m_amount = amount; }
void setSortOrder( DatabaseCommand_AllArtists::SortOrder order ) { m_sortOrder = order; }
void setSortDescending( bool descending ) { m_sortDescending = descending; }
void setFilter( const QString& filter ) { m_filter = filter; }
signals:
void artists( const QList<Tomahawk::artist_ptr>& );
@@ -65,7 +64,6 @@ private:
unsigned int m_amount;
DatabaseCommand_AllArtists::SortOrder m_sortOrder;
bool m_sortDescending;
QString m_filter;
};
#endif // DATABASECOMMAND_ALLARTISTS_H

View File

@@ -34,6 +34,7 @@ using namespace Tomahawk;
DropJob::DropJob( QObject *parent )
: QObject( parent )
, m_queryCount( 0 )
, m_dropFlags( DropFlagsNone )
{
}
@@ -98,31 +99,72 @@ DropJob::acceptsMimeData( const QMimeData* data, bool tracksOnly )
void
DropJob::setGetWholeArtists( bool getWholeArtists )
{
m_getWholeArtists = getWholeArtists;
if( getWholeArtists )
m_dropFlags |= DropFlagArtist;
else
m_dropFlags &= !DropFlagArtist;
}
void
DropJob::setGetWholeAlbums( bool getWholeAlbums )
{
m_getWholeAlbums = getWholeAlbums;
if ( getWholeAlbums )
m_dropFlags |= DropFlagAlbum;
else
m_dropFlags &= !DropFlagAlbum;
}
void
DropJob::tracksFromMimeData( const QMimeData* data, bool allowDuplicates, bool onlyLocal, bool top10 )
DropJob::setGetTop10( bool top10 )
{
m_allowDuplicates = allowDuplicates;
m_onlyLocal = onlyLocal;
m_top10 = top10;
if( top10 )
m_dropFlags |= DropFlagTop10;
else
m_dropFlags &= !DropFlagTop10;
}
void
DropJob::setOnlyLocal( bool onlyLocal )
{
if( onlyLocal )
m_dropFlags |= DropFlagLocal;
else
m_dropFlags &= !DropFlagLocal;
}
void
DropJob::setAllowDuplicates( bool allowDuplicates )
{
if( allowDuplicates )
m_dropFlags |= DropFlagAllowDuplicates;
else
m_dropFlags &= !DropFlagAllowDuplicates;
}
void
DropJob::setDropFlags( DropFlags flags )
{
m_dropFlags = flags;
}
void
DropJob::tracksFromMimeData( const QMimeData* data )
{
parseMimeData( data );
if ( m_queryCount == 0 )
{
if ( onlyLocal )
if ( m_dropFlags.testFlag( DropFlagLocal ) )
removeRemoteSources();
if ( !allowDuplicates )
if ( !m_dropFlags.testFlag( DropFlagAllowDuplicates ) )
removeDuplicates();
emit tracks( m_resultList );
@@ -171,15 +213,15 @@ DropJob::tracksFromQueryList( const QMimeData* data )
{
tDebug() << "Dropped query item:" << query->data()->artist() << "-" << query->data()->track();
if ( m_top10 )
if ( m_dropFlags.testFlag( DropFlagTop10 ) )
{
getTopTen( query->data()->artist() );
}
else if ( m_getWholeArtists )
else if ( m_dropFlags.testFlag( DropFlagArtist ) )
{
queries << getArtist( query->data()->artist() );
}
else if ( m_getWholeAlbums )
else if ( m_dropFlags.testFlag( DropFlagAlbum ) )
{
queries << getAlbum( query->data()->artist(), query->data()->album() );
}
@@ -211,15 +253,15 @@ DropJob::tracksFromResultList( const QMimeData* data )
tDebug() << "Dropped result item:" << result->data()->artist()->name() << "-" << result->data()->track();
query_ptr q = result->data()->toQuery();
if ( m_top10 )
if ( m_dropFlags.testFlag( DropFlagTop10 ) )
{
getTopTen( q->artist() );
}
else if ( m_getWholeArtists )
else if ( m_dropFlags.testFlag( DropFlagArtist ) )
{
queries << getArtist( q->artist() );
}
else if ( m_getWholeAlbums )
else if ( m_dropFlags.testFlag( DropFlagAlbum ) )
{
queries << getAlbum( q->artist(), q->album() );
}
@@ -248,9 +290,9 @@ DropJob::tracksFromAlbumMetaData( const QMimeData *data )
QString album;
stream >> album;
if ( m_top10 )
if ( m_dropFlags.testFlag( DropFlagTop10 ) )
getTopTen( artist );
else if ( m_getWholeArtists )
else if ( m_dropFlags.testFlag( DropFlagArtist ) )
queries << getArtist( artist );
else
queries << getAlbum( artist, album );
@@ -270,14 +312,10 @@ DropJob::tracksFromArtistMetaData( const QMimeData *data )
QString artist;
stream >> artist;
if ( !m_top10 )
{
queries << getArtist( artist );
}
else
{
if ( m_dropFlags.testFlag( DropFlagTop10 ) )
getTopTen( artist );
}
else
queries << getArtist( artist );
}
return queries;
}
@@ -381,10 +419,10 @@ DropJob::onTracksAdded( const QList<Tomahawk::query_ptr>& tracksList )
if ( --m_queryCount == 0 )
{
if ( m_onlyLocal )
if ( m_dropFlags.testFlag( DropFlagLocal ) )
removeRemoteSources();
if ( !m_allowDuplicates )
if ( !m_dropFlags.testFlag( DropFlagAllowDuplicates ) )
removeDuplicates();
emit tracks( m_resultList );

View File

@@ -28,10 +28,48 @@
#include <QStringList>
#include <QMimeData>
/** @class DropJob
* Allows you to process dropped mimedata in different ways:
* Configure the DropJob using setDropFlags() or the set*() functions to do
* what you want and then feed it with MimeMata. Connect to the tracks() signal
* to receive the results.
*
* Possible configuration flags are:
* - DropFlagTrack: Get the dropped track (only valid if the dropped item is acutally a track)
* - DropFlagAlbum: Get this album (only valid if the dropped item is an album or a track with album information)
* - DropFlagArtist: Get this artist
* - DropFlagTop10: Query the Top 10 for this artist in the Network
* - DropFlagLocal: Only get local items (Filters out all remote ones)
* - DropFlagAllowDuplicates: Allow duplicate results, e.g. same song from different sources.
*
* Note: The largest possible set of the configured Flags applies. E.g. Artist is greater than Album.
* If you set both of them only the album will be fetched. Requesting the Top 10 items always results in a
* query for the whole artist. It is not possible to e.g. request the Top 10 tracks of a given album.
*
* If you configure nothing or dropping incompatible data (e.g. configured DropTrack but dropping an album),
* the DropJob will do this default actions:
* - Get this track for dropped tracks
* - Get whole album for dropped albums
* - Get whole artist for dropped artists
*/
class DLLEXPORT DropJob : public QObject
{
Q_OBJECT
public:
enum DropFlag
{
DropFlagsNone = 0x00,
DropFlagTrack = 0x01,
DropFlagAlbum = 0x02,
DropFlagArtist = 0x04,
DropFlagTop10 = 0x08,
DropFlagLocal = 0x10,
DropFlagAllowDuplicates = 0x20,
DropFlagsAll = 0xff
};
Q_DECLARE_FLAGS( DropFlags, DropFlag )
explicit DropJob( QObject *parent = 0 );
~DropJob();
@@ -46,9 +84,15 @@ public:
static bool acceptsMimeData( const QMimeData* data, bool tracksOnly = true );
static QStringList mimeTypes();
void setDropFlags( DropFlags flags );
void setGetWholeArtists( bool getWholeArtists );
void setGetWholeAlbums( bool getWholeAlbums );
void tracksFromMimeData( const QMimeData* data, bool allowDuplicates = false, bool onlyLocal = false, bool top10 = false );
void setGetTop10( bool top10 );
void setOnlyLocal( bool onlyLocal );
void setAllowDuplicates( bool allowDuplicates );
void tracksFromMimeData( const QMimeData* data );
signals:
/// QMimeData parsing results
@@ -81,13 +125,10 @@ private:
void removeRemoteSources();
int m_queryCount;
bool m_allowDuplicates;
bool m_onlyLocal;
bool m_getWholeArtists;
bool m_getWholeAlbums;
bool m_top10;
DropFlags m_dropFlags;
QList< Tomahawk::query_ptr > m_resultList;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( DropJob::DropFlags )
#endif // DROPJOB_H

View File

@@ -39,7 +39,7 @@ public:
virtual ~GlobalActionManager();
QUrl openLinkFromQuery( const Tomahawk::query_ptr& query ) const;
Q_INVOKABLE QUrl openLink( const QString& title, const QString& artist, const QString& album ) const;
QUrl openLink( const QString& title, const QString& artist, const QString& album ) const;
/// Takes a spotify link and performs the default open action on it
bool openSpotifyLink( const QString& link );

View File

@@ -22,7 +22,6 @@
#include <QSettings>
#include <QCryptographicHash>
#include <QNetworkConfiguration>
#include <QDomElement>
#include "album.h"
#include "typedefs.h"
@@ -50,7 +49,7 @@ LastFmPlugin::LastFmPlugin()
: InfoPlugin()
, m_scrobbler( 0 )
{
m_supportedGetTypes << InfoAlbumCoverArt << InfoArtistImages << InfoArtistSimilars << InfoArtistSongs << InfoChart << InfoChartCapabilities;
m_supportedGetTypes << InfoAlbumCoverArt << InfoArtistImages << InfoArtistSimilars << InfoArtistSongs << InfoChartArtists << InfoChartTracks << InfoChartCapabilities;
m_supportedPushTypes << InfoSubmitScrobble << InfoSubmitNowPlaying << InfoLove << InfoUnLove;
/*
@@ -151,10 +150,13 @@ LastFmPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData req
fetchTopTracks( requestId, requestData );
break;
case InfoChart:
fetchChart( requestId, requestData );
case InfoChartArtists:
fetchChartArtists( requestId, requestData );
break;
case InfoChartTracks:
fetchChartTracks( requestId, requestData );
break;
case InfoChartCapabilities:
fetchChartCapabilities( requestId, requestData );
break;
@@ -310,7 +312,7 @@ LastFmPlugin::fetchTopTracks( uint requestId, Tomahawk::InfoSystem::InfoRequestD
}
void
LastFmPlugin::fetchChart( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
LastFmPlugin::fetchChartArtists( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
{
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
{
@@ -319,17 +321,34 @@ LastFmPlugin::fetchChart( uint requestId, Tomahawk::InfoSystem::InfoRequestData
}
InfoCriteriaHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
if ( !hash.contains( "chart_id" ) )
if ( hash.contains( "country" ) )
{
criteria["country"] = hash["country"];
}
emit getCachedInfo( requestId, criteria, 2419200000, requestData );
}
void
LastFmPlugin::fetchChartTracks( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
{
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
{
dataError( requestId, requestData );
return;
} else {
criteria["chart_id"] = hash["chart_id"];
}
InfoCriteriaHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
if ( hash.contains( "country" ) )
{
criteria["country"] = hash["country"];
}
emit getCachedInfo( requestId, criteria, 0, requestData );
emit getCachedInfo( requestId, criteria, 2419200000, requestData );
}
void
LastFmPlugin::fetchChartCapabilities( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
{
@@ -341,7 +360,7 @@ LastFmPlugin::fetchChartCapabilities( uint requestId, Tomahawk::InfoSystem::Info
InfoCriteriaHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
emit getCachedInfo( requestId, criteria, 0, requestData );
emit getCachedInfo( requestId, criteria, 2419200000, requestData );
}
void
@@ -401,39 +420,57 @@ LastFmPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
switch ( requestData.type )
{
case InfoChart:
case InfoChartArtists:
{
tDebug() << "LastFmPlugin: InfoChart not in cache, fetching";
tDebug() << "LastfmPlugin: InfoChartArtists notin cache, fetching";
QMap<QString, QString> args;
tDebug() << "LastFmPlugin: " << "args chart_id" << criteria["chart_id"];
args["method"] = criteria["chart_id"];
if( criteria.contains( "country" ) ) {
args["method"] = "geo.getTopArtists";
args["country"] = criteria["country"];
} else {
args["method"] = "chart.getTopArtists";
}
args["limit"] = "100";
QNetworkReply* reply = lastfm::ws::get(args);
reply->setProperty( "requestId", requestId );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) );
connect( reply, SIGNAL( finished() ), SLOT( chartTopArtistsReturned() ) );
return;
}
case InfoChartTracks:
{
tDebug() << "LastfmPlugin: InfoChartTracks not in cache, fetching";
QMap<QString, QString> args;
if( criteria.contains( "country" ) ) {
args["method"] = "geo.getTopTracks";
args["country"] = criteria["country"];
} else {
args["method"] = "chart.getTopTracks";
}
args["limit"] = "100";
QNetworkReply* reply = lastfm::ws::get(args);
reply->setProperty( "requestId", requestId );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( chartTopTracksReturned() ) );
return;
}
case InfoChartCapabilities:
{
QList<Chart> track_charts;
track_charts.append(Chart("chart.getTopTracks", "Top Tracks", "tracks"));
track_charts.append(Chart("chart.getLovedTracks", "Loved Tracks", "tracks"));
track_charts.append(Chart("chart.getHypedTracks", "Hyped Tracks", "tracks"));
QList<Chart> artist_charts;
artist_charts.append(Chart("chart.getTopArtists", "Top Artists", "artists"));
artist_charts.append(Chart("chart.getHypedArtists", "Hyped Artists", "artists"));
QVariantMap charts;
charts.insert("Tracks", QVariant::fromValue<QList<Chart> >(track_charts));
charts.insert("Artists", QVariant::fromValue<QList<Chart> >(artist_charts));
QVariantMap result;
result.insert("Last.fm", QVariant::fromValue<QVariantMap>(charts));
tDebug() << "LastfmPlugin: InfoChartCapabilities not in cache, fetching";
QString json("{'Last.fm': {'Tracks': ['Top Tracks','Hyped Tracks','Most Loved Tracks'],"
"'Artists': ['Top Artists', 'Hyped Artists']}}");
json.replace("'", "\"");
QJson::Parser parser;
bool ok = false;
QVariantMap result = parser.parse (json.toUtf8(), &ok).toMap();
if(!ok) {
tDebug() << "Lastfm Plugin: parsing json failed";
return;
}
emit info(
requestId,
requestData,
@@ -534,40 +571,20 @@ LastFmPlugin::similarArtistsReturned()
}
void
LastFmPlugin::chartReturned()
LastFmPlugin::chartTopArtistsReturned()
{
tDebug() << "LastfmPlugin: InfoChart data returned!";
tDebug() << "LastfmPlugin: InfoChartArtists data returned!";
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
QList<lastfm::Artist> list = lastfm::Artist::list( reply );
QStringList al;
tDebug() << "\tgot " << list.size() << " artists";
foreach ( const lastfm::Artist& a, list )
al << a.toString();
QVariantMap returnedData;
const QRegExp tracks_rx( "chart\\.\\S+tracks\\S*", Qt::CaseInsensitive );
const QRegExp artists_rx( "chart\\.\\S+artists\\S*", Qt::CaseInsensitive );
const QString url = reply->url().toString();
if( url.contains( tracks_rx ) ) {
QList<lastfm::Track> tracks = parseTrackList( reply );
QList<ArtistTrackPair> top_tracks;
foreach( const lastfm::Track &t, tracks ) {
ArtistTrackPair pair;
pair.artist = t.artist().toString();
pair.track = t.title();
top_tracks << pair;
}
tDebug() << "LastFmPlugin:" << "\tgot " << top_tracks.size() << " tracks";
returnedData["tracks"] = QVariant::fromValue( top_tracks );
returnedData["type"] = "tracks";
} else if( url.contains( artists_rx ) ) {
QList<lastfm::Artist> list = lastfm::Artist::list( reply );
QStringList al;
tDebug() << "LastFmPlugin:"<< "\tgot " << list.size() << " artists";
foreach ( const lastfm::Artist& a, list )
al << a.toString();
returnedData["artists"] = al;
returnedData["type"] = "artists";
} else {
tDebug() << "LastfmPlugin:: got non tracks and non artists";
}
returnedData["artists"] = al;
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
@@ -576,7 +593,48 @@ LastFmPlugin::chartReturned()
requestData,
returnedData
);
// TODO update cache
Tomahawk::InfoSystem::InfoCriteriaHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash>();
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
if( origData.contains("country") )
criteria["country"] = origData["country"];
emit updateCache( criteria, 2419200000, requestData.type, returnedData );
}
void
LastFmPlugin::chartTopTracksReturned()
{
tDebug() << "LastfmPlugin: InfoChartTracks data returned!";
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
QList<lastfm::Track> tracks = parseTrackList( reply );
QList<ArtistTrackPair> top_tracks;
foreach( const lastfm::Track &t, tracks ) {
ArtistTrackPair pair;
pair.artist = t.artist().toString();
pair.track = t.title();
top_tracks << pair;
}
tDebug() << "\tgot " << top_tracks.size() << " tracks";
QVariantMap returnedData;
returnedData["tracks"] = QVariant::fromValue( top_tracks );
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
emit info(
reply->property( "requestId" ).toUInt(),
requestData,
returnedData
);
Tomahawk::InfoSystem::InfoCriteriaHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash>();
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
if( origData.contains("country") )
criteria["country"] = origData["country"];
emit updateCache( criteria, 0, requestData.type, returnedData );
}
void

View File

@@ -52,7 +52,8 @@ public slots:
void artistImagesReturned();
void similarArtistsReturned();
void topTracksReturned();
void chartReturned();
void chartTopArtistsReturned();
void chartTopTracksReturned();
void namChangedSlot( QNetworkAccessManager *nam );
@@ -67,7 +68,8 @@ private:
void fetchArtistImages( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
void fetchSimilarArtists( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
void fetchTopTracks( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
void fetchChart( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
void fetchChartArtists( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
void fetchChartTracks( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
void fetchChartCapabilities( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
void createScrobbler();

View File

@@ -102,7 +102,9 @@ enum InfoType { // as items are saved in cache, mark them here to not change the
/**
* Documentation for InfoChartArtists
*/
InfoChart = 51,
InfoChartArtists = 51,
InfoChartAlbums = 52, /*!< Documentation for InfoChartAlbums */
InfoChartTracks = 53,
InfoMiscTopHotttness = 60,
InfoMiscTopTerms = 61,
@@ -135,18 +137,6 @@ struct ArtistTrackPair {
QString track;
};
struct Chart {
Chart(){}
Chart(const QString _id, const QString _label, const QString _type) {
id = _id;
label = _label;
type = _type;
}
QString id;
QString label;
QString type;
};
typedef QMap< InfoType, QVariant > InfoTypeMap;
typedef QMap< InfoType, uint > InfoTimeoutMap;
typedef QMap< QString, QMap< QString, QString > > InfoGenericMap;
@@ -284,8 +274,6 @@ Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoGenericMap );
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCriteriaHash );
Q_DECLARE_METATYPE( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache > );
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::ArtistTrackPair );
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::Chart );
Q_DECLARE_METATYPE( QList<Tomahawk::InfoSystem::ArtistTrackPair> );
Q_DECLARE_METATYPE( QList<Tomahawk::InfoSystem::Chart> );
#endif // TOMAHAWK_INFOSYSTEM_H

View File

@@ -1,143 +0,0 @@
/* === 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 "ViewHeader.h"
#include <QContextMenuEvent>
#include <QMenu>
#include "tomahawksettings.h"
#include "utils/logger.h"
ViewHeader::ViewHeader( QAbstractItemView* parent )
: QHeaderView( Qt::Horizontal, parent )
, m_parent( parent )
, m_menu( new QMenu( this ) )
, m_sigmap( new QSignalMapper( this ) )
, m_init( false )
{
setResizeMode( QHeaderView::Interactive );
setMinimumSectionSize( 60 );
setDefaultAlignment( Qt::AlignLeft );
setMovable( true );
setStretchLastSection( true );
// m_menu->addAction( tr( "Resize columns to fit window" ), this, SLOT( onToggleResizeColumns() ) );
// m_menu->addSeparator();
connect( m_sigmap, SIGNAL( mapped( int ) ), SLOT( toggleVisibility( int ) ) );
}
ViewHeader::~ViewHeader()
{
}
int
ViewHeader::visibleSectionCount() const
{
return count() - hiddenSectionCount();
}
void
ViewHeader::onSectionsChanged()
{
TomahawkSettings::instance()->setPlaylistColumnSizes( m_guid, saveState() );
}
bool
ViewHeader::checkState()
{
if ( !count() || m_init )
return false;
QByteArray state = TomahawkSettings::instance()->playlistColumnSizes( m_guid );
if ( !state.isEmpty() )
{
restoreState( state );
if ( m_guid.startsWith( "playlistview" ) ) // HACK
setSortIndicator( -1, Qt::AscendingOrder );
}
else
{
for ( int i = 0; i < count() - 1; i++ )
{
if ( isSectionHidden( i ) )
continue;
double nw = (double)m_parent->width() * m_columnWeights.at( i );
resizeSection( i, qMax( minimumSectionSize(), int( nw - 0.5 ) ) );
}
}
m_init = true;
connect( this, SIGNAL( sectionMoved( int, int, int ) ), SLOT( onSectionsChanged() ) );
connect( this, SIGNAL( sectionResized( int, int, int ) ), SLOT( onSectionsChanged() ) );
return true;
}
void
ViewHeader::addColumnToMenu( int index )
{
QString title = m_parent->model()->headerData( index, Qt::Horizontal, Qt::DisplayRole ).toString();
QAction* action = m_menu->addAction( title, m_sigmap, SLOT( map() ) );
action->setCheckable( true );
action->setChecked( !isSectionHidden( index ) );
m_visActions << action;
m_sigmap->setMapping( action, index );
}
void
ViewHeader::contextMenuEvent( QContextMenuEvent* e )
{
qDeleteAll( m_visActions );
m_visActions.clear();
for ( int i = 0; i < count(); i++ )
addColumnToMenu( i );
m_menu->popup( e->globalPos() );
}
void
ViewHeader::onToggleResizeColumns()
{
}
void
ViewHeader::toggleVisibility( int index )
{
qDebug() << Q_FUNC_INFO << index;
if ( isSectionHidden( index ) )
showSection( index );
else
hideSection( index );
}

View File

@@ -1,65 +0,0 @@
/* === 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 VIEWHEADER_H
#define VIEWHEADER_H
#include <QHeaderView>
#include <QSignalMapper>
#include "dllmacro.h"
class DLLEXPORT ViewHeader : public QHeaderView
{
Q_OBJECT
public:
explicit ViewHeader( QAbstractItemView* parent = 0 );
~ViewHeader();
int visibleSectionCount() const;
void setDefaultColumnWeights( QList<double> weights ) { m_columnWeights = weights; }
QString guid() const { return m_guid; }
void setGuid( const QString& guid ) { m_guid = guid; }
public slots:
void toggleVisibility( int index );
bool checkState();
protected:
void contextMenuEvent( QContextMenuEvent* e );
private slots:
virtual void onSectionsChanged();
void onToggleResizeColumns();
private:
void addColumnToMenu( int index );
QAbstractItemView* m_parent;
QString m_guid;
QList<double> m_columnWeights;
QMenu* m_menu;
QSignalMapper* m_sigmap;
QList<QAction*> m_visActions;
bool m_init;
};
#endif

View File

@@ -25,7 +25,6 @@
#include "audio/audioengine.h"
#include "dynamic/widgets/LoadingSpinner.h"
#include "widgets/overlaywidget.h"
#include "tomahawksettings.h"
#include "treeheader.h"
@@ -41,7 +40,6 @@ using namespace Tomahawk;
ArtistView::ArtistView( QWidget* parent )
: QTreeView( parent )
, m_header( new TreeHeader( this ) )
, m_overlay( new OverlayWidget( this ) )
, m_model( 0 )
, m_proxyModel( 0 )
// , m_delegate( 0 )
@@ -126,13 +124,10 @@ ArtistView::setTreeModel( TreeModel* model )
connect( m_model, SIGNAL( loadingStarted() ), m_loadingSpinner, SLOT( fadeIn() ) );
connect( m_model, SIGNAL( loadingFinished() ), m_loadingSpinner, SLOT( fadeOut() ) );
connect( m_proxyModel, SIGNAL( filteringStarted() ), SLOT( onFilteringStarted() ) );
connect( m_proxyModel, SIGNAL( filteringFinished() ), m_loadingSpinner, SLOT( fadeOut() ) );
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
guid(); // this will set the guid on the header
setAcceptDrops( false );
if ( model->columnStyle() == TreeModel::TrackOnly )
@@ -207,23 +202,6 @@ ArtistView::onFilterChanged( const QString& )
{
if ( selectedIndexes().count() )
scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter );
if ( !proxyModel()->filter().isEmpty() && !proxyModel()->trackCount() && model()->trackCount() )
{
m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->filter() ) );
m_overlay->show();
}
else
if ( model()->trackCount() )
m_overlay->hide();
}
void
ArtistView::onFilteringStarted()
{
m_overlay->hide();
m_loadingSpinner->fadeIn();
}
@@ -372,10 +350,7 @@ QString
ArtistView::guid() const
{
if ( m_guid.isEmpty() )
{
m_guid = QString( "artistview/%1" ).arg( m_model->columnCount( QModelIndex() ) );
m_header->setGuid( m_guid );
}
return m_guid;
}

View File

@@ -31,7 +31,6 @@
class TreeHeader;
class LoadingSpinner;
class OverlayWidget;
class DLLEXPORT ArtistView : public QTreeView, public Tomahawk::ViewPage
{
@@ -48,8 +47,7 @@ public:
TreeModel* model() const { return m_model; }
TreeProxyModel* proxyModel() const { return m_proxyModel; }
OverlayWidget* overlay() const { return m_overlay; }
// PlaylistItemDelegate* delegate() { return m_delegate; }
// PlaylistItemDelegate* delegate() { return m_delegate; }
void setModel( QAbstractItemModel* model );
void setTreeModel( TreeModel* model );
@@ -62,7 +60,7 @@ public:
virtual QPixmap pixmap() const { return QPixmap( RESPATH "images/music-icon.png" ); }
virtual bool showStatsBar() const { return false; }
virtual bool showFilter() const { return true; }
virtual bool showFilter() const { return false; }
virtual void setShowModes( bool b ) { m_showModes = b; }
virtual bool showModes() const { return m_showModes; }
@@ -81,7 +79,6 @@ protected:
private slots:
void onFilterChanged( const QString& filter );
void onFilteringStarted();
void onViewChanged();
void onScrollTimeout();
@@ -90,12 +87,11 @@ private slots:
private:
TreeHeader* m_header;
OverlayWidget* m_overlay;
TreeModel* m_model;
TreeProxyModel* m_proxyModel;
// PlaylistItemDelegate* m_delegate;
LoadingSpinner* m_loadingSpinner;
LoadingSpinner* m_loadingSpinner;
QModelIndex m_contextMenuIndex;
Tomahawk::ContextMenu* m_contextMenu;

View File

@@ -23,7 +23,7 @@
#include "dynamic/GeneratorInterface.h"
#include "dynamic/DynamicControl.h"
#include "utils/tomahawkutils.h"
#include "widgets/elidedlabel.h"
#include "utils/elidedlabel.h"
#include <QLabel>
#include <QStackedLayout>

View File

@@ -22,8 +22,7 @@
#include <QLabel>
#include <QPixmap>
#include "viewmanager.h"
#include "thirdparty/Qocoa/qsearchfield.h"
#include "context/ContextWidget.h"
#include "utils/tomahawkutils.h"
#include "utils/logger.h"
@@ -70,23 +69,7 @@ InfoBar::InfoBar( QWidget* parent )
ui->longDescriptionLabel->setText( QString() );
ui->imageLabel->setText( QString() );
m_searchWidget = new QSearchField( this );
m_searchWidget->setPlaceholderText( tr( "Filter..." ) );
m_searchWidget->setMinimumWidth( 180 );
connect( m_searchWidget, SIGNAL( textChanged( QString ) ), this, SLOT( onFilterEdited() ) );
ui->horizontalLayout->addWidget( m_searchWidget );
QLinearGradient gradient = QLinearGradient( QPoint( 0, 0 ), QPoint( 500, 200 ) ); //HACK
gradient.setColorAt( 0.0, QColor( 100, 100, 100 ) );
gradient.setColorAt( 0.8, QColor( 63, 63, 63 ) );
QPalette p = palette();
p.setBrush( QPalette::Window, QBrush( gradient ) );
setPalette( p );
setAutoFillBackground( true );
connect( ViewManager::instance(), SIGNAL( filterAvailable( bool ) ), SLOT( setFilterAvailable( bool ) ) );
}
@@ -134,27 +117,6 @@ InfoBar::setPixmap( const QPixmap& p )
}
void
InfoBar::setFilter( const QString& filter )
{
m_searchWidget->setText( filter );
}
void
InfoBar::setFilterAvailable( bool b )
{
m_searchWidget->setVisible( b );
}
void
InfoBar::onFilterEdited()
{
emit filterTextChanged( m_searchWidget->text() );
}
void
InfoBar::changeEvent( QEvent* e )
{
@@ -169,3 +131,18 @@ InfoBar::changeEvent( QEvent* e )
break;
}
}
void
InfoBar::resizeEvent( QResizeEvent* e )
{
QWidget::resizeEvent( e );
QLinearGradient gradient = QLinearGradient( contentsRect().topLeft(), contentsRect().bottomRight() );
gradient.setColorAt( 0.0, QColor( 100, 100, 100 ) );
gradient.setColorAt( 1.0, QColor( 63, 63, 63 ) );
QPalette p = palette();
p.setBrush( QPalette::Window, QBrush( gradient ) );
setPalette( p );
}

View File

@@ -22,10 +22,10 @@
#include <QWidget>
#include "dllmacro.h"
#include "query.h"
class QTimeLine;
class QSearchField;
class ContextWidget;
namespace Ui
@@ -47,22 +47,12 @@ public slots:
void setLongDescription( const QString& s );
void setPixmap( const QPixmap& p );
void setFilter( const QString& filter );
void setFilterAvailable( bool b );
signals:
void filterTextChanged( const QString& filter );
protected:
void changeEvent( QEvent* e );
private slots:
void onFilterEdited();
void resizeEvent( QResizeEvent* e );
private:
Ui::InfoBar* ui;
QSearchField* m_searchWidget;
};
#endif // INFOBAR_H

View File

@@ -121,7 +121,7 @@
<enum>QLayout::SetMaximumSize</enum>
</property>
<item>
<widget class="ElidedLabel" name="longDescriptionLabel">
<widget class="QLabel" name="longDescriptionLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -174,7 +174,7 @@
<customwidget>
<class>ElidedLabel</class>
<extends>QLabel</extends>
<header>widgets/elidedlabel.h</header>
<header>utils/elidedlabel.h</header>
</customwidget>
</customwidgets>
<resources/>

View File

@@ -21,7 +21,7 @@
#include <QPushButton>
#include "widgets/animatedsplitter.h"
#include "utils/animatedsplitter.h"
#include "playlistview.h"
#include "dllmacro.h"

View File

@@ -311,7 +311,7 @@
<customwidget>
<class>AnimatedCounterLabel</class>
<extends>QLabel</extends>
<header>widgets/animatedcounterlabel.h</header>
<header>utils/animatedcounterlabel.h</header>
</customwidget>
<customwidget>
<class>SearchLineEdit</class>

View File

@@ -18,21 +18,134 @@
#include "trackheader.h"
#include <QContextMenuEvent>
#include <QMenu>
#include "tomahawksettings.h"
#include "playlist/trackmodel.h"
#include "playlist/trackview.h"
#include "utils/logger.h"
TrackHeader::TrackHeader( TrackView* parent )
: ViewHeader( parent )
: QHeaderView( Qt::Horizontal, parent )
, m_parent( parent )
, m_menu( new QMenu( this ) )
, m_sigmap( new QSignalMapper( this ) )
, m_init( false )
{
QList< double > columnWeights;
columnWeights << 0.18 << 0.18 << 0.17 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.10; // << 0.05;
setResizeMode( QHeaderView::Interactive );
setMinimumSectionSize( 60 );
setDefaultAlignment( Qt::AlignLeft );
setMovable( true );
setStretchLastSection( true );
// setCascadingSectionResizes( true );
setDefaultColumnWeights( columnWeights );
// m_menu->addAction( tr( "Resize columns to fit window" ), this, SLOT( onToggleResizeColumns() ) );
// m_menu->addSeparator();
connect( this, SIGNAL( sectionResized( int, int, int ) ), SLOT( onSectionResized() ) );
connect( m_sigmap, SIGNAL( mapped( int ) ), SLOT( toggleVisibility( int ) ) );
}
TrackHeader::~TrackHeader()
{
}
void
TrackHeader::onSectionResized()
{
if ( !m_init )
return;
TomahawkSettings::instance()->setPlaylistColumnSizes( m_parent->guid(), saveState() );
}
int
TrackHeader::visibleSectionCount() const
{
return count() - hiddenSectionCount();
}
bool
TrackHeader::checkState()
{
if ( !count() || m_init )
return false;
QByteArray state = TomahawkSettings::instance()->playlistColumnSizes( m_parent->guid() );
if ( !state.isEmpty() )
{
restoreState( state );
if ( m_parent->guid().startsWith( "playlistview" ) ) // HACK
setSortIndicator( -1, Qt::AscendingOrder );
}
else
{
QList< double > m_columnWeights;
m_columnWeights << 0.18 << 0.18 << 0.17 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.10; // << 0.05;
for ( int i = 0; i < count() - 1; i++ )
{
if ( isSectionHidden( i ) )
continue;
double nw = (double)m_parent->width() * m_columnWeights.at( i );
qDebug() << "Setting default size:" << i << nw;
resizeSection( i, qMax( minimumSectionSize(), int( nw - 0.5 ) ) );
}
}
m_init = true;
return true;
}
void
TrackHeader::addColumnToMenu( int index )
{
QString title = m_parent->model()->headerData( index, Qt::Horizontal, Qt::DisplayRole ).toString();
QAction* action = m_menu->addAction( title, m_sigmap, SLOT( map() ) );
action->setCheckable( true );
action->setChecked( !isSectionHidden( index ) );
m_visActions << action;
m_sigmap->setMapping( action, index );
}
void
TrackHeader::contextMenuEvent( QContextMenuEvent* e )
{
qDeleteAll( m_visActions );
m_visActions.clear();
for ( int i = 0; i < count(); i++ )
addColumnToMenu( i );
m_menu->popup( e->globalPos() );
}
void
TrackHeader::onToggleResizeColumns()
{
}
void
TrackHeader::toggleVisibility( int index )
{
qDebug() << Q_FUNC_INFO << index;
if ( isSectionHidden( index ) )
showSection( index );
else
hideSection( index );
}

View File

@@ -19,12 +19,16 @@
#ifndef TRACKHEADER_H
#define TRACKHEADER_H
#include "ViewHeader.h"
#include <QHeaderView>
#include <QSignalMapper>
#include "source.h"
#include "dllmacro.h"
class TrackView;
class DLLEXPORT TrackHeader : public ViewHeader
class DLLEXPORT TrackHeader : public QHeaderView
{
Q_OBJECT
@@ -32,8 +36,28 @@ public:
explicit TrackHeader( TrackView* parent = 0 );
~TrackHeader();
int visibleSectionCount() const;
public slots:
void toggleVisibility( int index );
bool checkState();
protected:
void contextMenuEvent( QContextMenuEvent* e );
private slots:
void onSectionResized();
void onToggleResizeColumns();
private:
void addColumnToMenu( int index );
TrackView* m_parent;
QMenu* m_menu;
QSignalMapper* m_sigmap;
QList<QAction*> m_visActions;
bool m_init;
};
#endif

View File

@@ -65,6 +65,7 @@ TrackProxyModel::setSourceTrackModel( TrackModel* sourceModel )
void
TrackProxyModel::setFilter( const QString& pattern )
{
qDebug() << Q_FUNC_INFO;
PlaylistInterface::setFilter( pattern );
setFilterRegExp( pattern );
@@ -181,7 +182,6 @@ TrackProxyModel::currentItem() const
return Tomahawk::result_ptr();
}
bool
TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
{

View File

@@ -98,7 +98,6 @@ void
TrackView::setGuid( const QString& guid )
{
m_guid = guid;
m_header->setGuid( guid );
}
@@ -364,7 +363,8 @@ TrackView::onFilterChanged( const QString& )
if ( selectedIndexes().count() )
scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter );
if ( !proxyModel()->filter().isEmpty() && !proxyModel()->trackCount() && model()->trackCount() )
if ( !proxyModel()->filter().isEmpty() && !proxyModel()->trackCount() &&
model()->trackCount() )
{
m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->filter() ) );
m_overlay->show();

View File

@@ -18,21 +18,128 @@
#include "treeheader.h"
#include <QContextMenuEvent>
#include <QMenu>
#include "tomahawksettings.h"
#include "playlist/treemodel.h"
#include "playlist/artistview.h"
#include "utils/logger.h"
TreeHeader::TreeHeader( ArtistView* parent )
: ViewHeader( parent )
: QHeaderView( Qt::Horizontal, parent )
, m_parent( parent )
, m_menu( new QMenu( this ) )
, m_sigmap( new QSignalMapper( this ) )
, m_init( false )
{
QList< double > columnWeights;
columnWeights << 0.50 << 0.07 << 0.07 << 0.07 << 0.07 << 0.07; // << 0.12;
setResizeMode( QHeaderView::Interactive );
setMinimumSectionSize( 60 );
setDefaultAlignment( Qt::AlignLeft );
setMovable( true );
setStretchLastSection( true );
// setCascadingSectionResizes( true );
setDefaultColumnWeights( columnWeights );
// m_menu->addAction( tr( "Resize columns to fit window" ), this, SLOT( onToggleResizeColumns() ) );
// m_menu->addSeparator();
connect( this, SIGNAL( sectionResized( int, int, int ) ), SLOT( onSectionResized() ) );
connect( m_sigmap, SIGNAL( mapped( int ) ), SLOT( toggleVisibility( int ) ) );
}
TreeHeader::~TreeHeader()
{
}
void
TreeHeader::onSectionResized()
{
if ( !m_init )
return;
TomahawkSettings::instance()->setPlaylistColumnSizes( m_parent->guid(), saveState() );
}
int
TreeHeader::visibleSectionCount() const
{
return count() - hiddenSectionCount();
}
void
TreeHeader::checkState()
{
if ( !count() || m_init )
return;
QByteArray state = TomahawkSettings::instance()->playlistColumnSizes( m_parent->guid() );
if ( !state.isEmpty() )
restoreState( state );
else
{
QList< double > m_columnWeights;
m_columnWeights << 0.50 << 0.07 << 0.07 << 0.07 << 0.07 << 0.07; // << 0.12;
for ( int i = 0; i < count() - 1; i++ )
{
if ( isSectionHidden( i ) )
continue;
double nw = (double)m_parent->width() * m_columnWeights.at( i );
qDebug() << "Setting default size:" << i << nw;
resizeSection( i, qMax( minimumSectionSize(), int( nw - 0.5 ) ) );
}
}
m_init = true;
}
void
TreeHeader::addColumnToMenu( int index )
{
QString title = m_parent->model()->headerData( index, Qt::Horizontal, Qt::DisplayRole ).toString();
QAction* action = m_menu->addAction( title, m_sigmap, SLOT( map() ) );
action->setCheckable( true );
action->setChecked( !isSectionHidden( index ) );
m_visActions << action;
m_sigmap->setMapping( action, index );
}
void
TreeHeader::contextMenuEvent( QContextMenuEvent* e )
{
qDeleteAll( m_visActions );
m_visActions.clear();
for ( int i = 0; i < count(); i++ )
addColumnToMenu( i );
m_menu->popup( e->globalPos() );
}
void
TreeHeader::onToggleResizeColumns()
{
}
void
TreeHeader::toggleVisibility( int index )
{
qDebug() << Q_FUNC_INFO << index;
if ( isSectionHidden( index ) )
showSection( index );
else
hideSection( index );
}

View File

@@ -19,12 +19,14 @@
#ifndef TREEHEADER_H
#define TREEHEADER_H
#include "ViewHeader.h"
#include <QHeaderView>
#include <QSignalMapper>
#include "dllmacro.h"
class ArtistView;
class DLLEXPORT TreeHeader : public ViewHeader
class DLLEXPORT TreeHeader : public QHeaderView
{
Q_OBJECT
@@ -32,8 +34,28 @@ public:
explicit TreeHeader( ArtistView* parent = 0 );
~TreeHeader();
int visibleSectionCount() const;
public slots:
void toggleVisibility( int index );
void checkState();
protected:
void contextMenuEvent( QContextMenuEvent* e );
private slots:
void onSectionResized();
void onToggleResizeColumns();
private:
void addColumnToMenu( int index );
ArtistView* m_parent;
QMenu* m_menu;
QSignalMapper* m_sigmap;
QList<QAction*> m_visActions;
bool m_init;
};
#endif

View File

@@ -49,11 +49,6 @@ TreeModel::TreeModel( QObject* parent )
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
QHash<int, QByteArray> roles;
roles[NameRole] = "name";
roles[IsPlayingRole] = "isPlaying";
setRoleNames(roles);
}
@@ -195,20 +190,6 @@ TreeModel::fetchMore( const QModelIndex& parent )
}
bool
TreeModel::hasChildren( const QModelIndex& parent ) const
{
TreeModelItem* parentItem = itemFromIndex( parent );
if ( !parentItem )
return false;
if ( parentItem == m_rootItem )
return true;
return ( !parentItem->artist().isNull() || !parentItem->album().isNull() );
}
int
TreeModel::rowCount( const QModelIndex& parent ) const
{
@@ -219,6 +200,12 @@ TreeModel::rowCount( const QModelIndex& parent ) const
if ( !parentItem )
return 0;
if ( !parentItem->artist().isNull() || !parentItem->album().isNull() )
{
if ( !parentItem->children.count() )
return 1;
}
return parentItem->children.count();
}
@@ -282,25 +269,17 @@ TreeModel::data( const QModelIndex& index, int role ) const
return QSize( 128, 0 );
}
if ( role != Qt::DisplayRole && !roleNames().contains( role ) ) // && role != Qt::ToolTipRole )
if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole )
return QVariant();
if ( role == IsPlayingRole )
return entry->isPlaying();
if ( !entry->artist().isNull() && ( index.column() == Name || role == NameRole ) )
if ( !entry->artist().isNull() && index.column() == Name )
{
return entry->artist()->name();
}
else if ( !entry->album().isNull() && ( index.column() == Name || role == NameRole ) )
else if ( !entry->album().isNull() && index.column() == Name )
{
return entry->album()->name();
}
else if ( role == NameRole )
{
return entry->result()->track();
}
else
{
const result_ptr& result = entry->result();
@@ -599,6 +578,7 @@ TreeModel::addTracks( const album_ptr& album, const QModelIndex& parent )
emit loadingStarted();
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_collection );
cmd->setAlbum( album.data() );
// cmd->setArtist( album->artist().data() );
QList< QVariant > rows;
rows << parent.row();
@@ -662,7 +642,6 @@ TreeModel::addFilteredCollection( const collection_ptr& collection, unsigned int
void
TreeModel::onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists )
{
emit loadingFinished();
if ( !artists.count() )
return;
@@ -682,12 +661,15 @@ TreeModel::onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists )
}
emit endInsertRows();
emit loadingFinished();
}
void
TreeModel::onAlbumsAdded( const QList<Tomahawk::album_ptr>& albums, const QVariant& data )
{
qDebug() << Q_FUNC_INFO << albums.count() << data.toInt();
emit loadingFinished();
if ( !albums.count() )
return;
@@ -700,7 +682,11 @@ TreeModel::onAlbumsAdded( const QList<Tomahawk::album_ptr>& albums, const QVaria
crows.first = c;
crows.second = c + albums.count() - 1;
emit beginInsertRows( parent, crows.first, crows.second );
if ( parent.isValid() )
crows.second -= 1;
if ( !parent.isValid() || crows.second > 0 )
emit beginInsertRows( parent, crows.first, crows.second );
TreeModelItem* albumitem = 0;
foreach( const album_ptr& album, albums )
@@ -712,13 +698,18 @@ TreeModel::onAlbumsAdded( const QList<Tomahawk::album_ptr>& albums, const QVaria
getCover( albumitem->index );
}
emit endInsertRows();
if ( !parent.isValid() || crows.second > 0 )
emit endInsertRows();
else
emit dataChanged( albumitem->index, albumitem->index.sibling( albumitem->index.row(), columnCount( QModelIndex() ) - 1 ) );
}
void
TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QVariant& data )
{
qDebug() << Q_FUNC_INFO << tracks.count();
emit loadingFinished();
if ( !tracks.count() )
return;
@@ -733,7 +724,11 @@ TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QVaria
crows.first = c;
crows.second = c + tracks.count() - 1;
emit beginInsertRows( parent, crows.first, crows.second );
if ( parent.isValid() )
crows.second -= 1;
if ( !parent.isValid() || crows.second > 0 )
emit beginInsertRows( parent, crows.first, crows.second );
TreeModelItem* item = 0;
foreach( const query_ptr& query, tracks )
@@ -745,7 +740,10 @@ TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QVaria
connect( item, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
}
emit endInsertRows();
if ( !parent.isValid() || crows.second > 0 )
emit endInsertRows();
emit dataChanged( item->index.sibling( 0, 0 ), item->index.sibling( item->index.row(), columnCount( QModelIndex() ) - 1 ) );
}
@@ -829,27 +827,3 @@ TreeModel::setColumnStyle( TreeModel::ColumnStyle style )
{
m_columnStyle = style;
}
QModelIndex
TreeModel::indexFromArtist( const Tomahawk::artist_ptr& artist ) const
{
for ( int i = 0; i < rowCount(); i++ )
{
QModelIndex idx = index( i, 0, QModelIndex() );
TreeModelItem* item = itemFromIndex( idx );
if ( item && item->artist() == artist )
{
return idx;
}
}
return QModelIndex();
}
QModelIndex
TreeModel::indexFromAlbum( const Tomahawk::album_ptr& album ) const
{
return QModelIndex();
}

View File

@@ -50,11 +50,6 @@ public:
AlbumPosition
};
enum Roles {
NameRole = Qt::UserRole + 1,
IsPlayingRole
};
enum ColumnStyle // Default style is AllColumns
{ AllColumns = 0, TrackOnly };
@@ -69,10 +64,8 @@ public:
virtual int trackCount() const { return rowCount( QModelIndex() ); }
virtual int albumCount() const { return rowCount( QModelIndex() ); }
virtual bool hasChildren( const QModelIndex& parent = QModelIndex() ) const;
virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const;
virtual int columnCount( const QModelIndex& parent = QModelIndex() ) const;
virtual int rowCount( const QModelIndex& parent ) const;
virtual int columnCount( const QModelIndex& parent ) const;
virtual void clear();
@@ -88,8 +81,6 @@ public:
virtual QPersistentModelIndex currentItem() { return m_currentIndex; }
Tomahawk::collection_ptr collection() const { return m_collection; }
void addAllCollections();
void addCollection( const Tomahawk::collection_ptr& collection );
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllArtists::SortOrder order );
@@ -108,9 +99,6 @@ public:
virtual void setTitle( const QString& title ) { m_title = title; }
virtual void setDescription( const QString& description ) { m_description = description; }
QModelIndex indexFromArtist( const Tomahawk::artist_ptr& artist ) const;
QModelIndex indexFromAlbum( const Tomahawk::album_ptr& album ) const;
TreeModelItem* itemFromIndex( const QModelIndex& index ) const
{
if ( index.isValid() )
@@ -163,8 +151,6 @@ private:
QString m_description;
ColumnStyle m_columnStyle;
QList<Tomahawk::artist_ptr> m_artistsFilter;
Tomahawk::collection_ptr m_collection;
QHash<qlonglong, QPersistentModelIndex> m_coverHash;
};

View File

@@ -21,15 +21,12 @@
#include <QListView>
#include "query.h"
#include "database/database.h"
#include "database/databasecommand_allalbums.h"
#include "utils/logger.h"
TreeProxyModel::TreeProxyModel( QObject* parent )
: QSortFilterProxyModel( parent )
, PlaylistInterface( this )
, m_artistsFilterCmd( 0 )
, m_model( 0 )
, m_repeatMode( PlaylistInterface::NoRepeat )
, m_shuffled( false )
@@ -56,120 +53,20 @@ TreeProxyModel::setSourceTreeModel( TreeModel* sourceModel )
{
m_model = sourceModel;
if ( m_model )
{
if ( m_model->metaObject()->indexOfSignal( "trackCountChanged(uint)" ) > -1 )
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SIGNAL( sourceTrackCountChanged( unsigned int ) ) );
connect( m_model, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onRowsInserted( QModelIndex, int, int ) ) );
}
if ( m_model && m_model->metaObject()->indexOfSignal( "trackCountChanged(uint)" ) > -1 )
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SIGNAL( sourceTrackCountChanged( unsigned int ) ) );
QSortFilterProxyModel::setSourceModel( sourceModel );
}
void
TreeProxyModel::onRowsInserted( const QModelIndex& parent, int /* start */, int /* end */ )
{
if ( m_filter.isEmpty() )
return;
if ( sender() != m_model )
return;
TreeModelItem* pi = m_model->itemFromIndex( m_model->index( parent.row(), 0, parent.parent() ) );
if ( pi->artist().isNull() )
return;
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( m_model->collection() );
cmd->setArtist( pi->artist() );
cmd->setFilter( m_filter );
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
SLOT( onFilterAlbums( QList<Tomahawk::album_ptr> ) ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
void
TreeProxyModel::setFilter( const QString& pattern )
{
emit filteringStarted();
qDebug() << Q_FUNC_INFO;
setFilterRegExp( pattern );
m_filter = pattern;
m_albumsFilter.clear();
if ( m_artistsFilterCmd )
{
disconnect( m_artistsFilterCmd, SIGNAL( artists( QList<Tomahawk::artist_ptr> ) ),
this, SLOT( onFilterArtists( QList<Tomahawk::artist_ptr> ) ) );
}
if ( m_filter.isEmpty() )
{
filterFinished();
}
else
{
DatabaseCommand_AllArtists* cmd = new DatabaseCommand_AllArtists( m_model->collection() );
cmd->setFilter( pattern );
m_artistsFilterCmd = cmd;
connect( cmd, SIGNAL( artists( QList<Tomahawk::artist_ptr> ) ),
SLOT( onFilterArtists( QList<Tomahawk::artist_ptr> ) ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
}
void
TreeProxyModel::onFilterArtists( const QList<Tomahawk::artist_ptr>& artists )
{
bool finished = true;
m_artistsFilter = artists;
foreach ( const Tomahawk::artist_ptr& artist, artists )
{
QModelIndex idx = m_model->indexFromArtist( artist );
if ( m_model->rowCount( idx ) )
{
finished = false;
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( m_model->collection() );
cmd->setArtist( artist );
cmd->setFilter( m_filter );
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
SLOT( onFilterAlbums( QList<Tomahawk::album_ptr> ) ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
}
if ( finished )
filterFinished();
}
void
TreeProxyModel::onFilterAlbums( const QList<Tomahawk::album_ptr>& albums )
{
m_albumsFilter << albums;
filterFinished();
}
void
TreeProxyModel::filterFinished()
{
m_artistsFilterCmd = 0;
PlaylistInterface::setFilter( m_filter );
setFilterRegExp( m_filter );
emit filterChanged( m_filter );
emit trackCountChanged( trackCount() );
emit filteringFinished();
emit filterChanged( pattern );
}
@@ -187,8 +84,7 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent
if ( result->track() == pi->result()->track() &&
( result->albumpos() == pi->result()->albumpos() || result->albumpos() == 0 ) )
{
if ( result.data() != pi->result().data() )
return false;
return ( result.data() == pi->result().data() );
}
}
@@ -210,34 +106,24 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent
}
}
// tDebug() << "Accepting:" << pi->result()->toString() << pi->result()->collection()->source()->id();
tDebug() << "Accepting:" << pi->result()->toString() << pi->result()->collection()->source()->id();
m_cache.insertMulti( sourceParent, pi->result() );
}
if ( m_filter.isEmpty() )
if ( filterRegExp().isEmpty() )
return true;
if ( !pi->artist().isNull() )
return m_artistsFilter.contains( pi->artist() );
if ( !pi->album().isNull() )
return m_albumsFilter.contains( pi->album() );
QStringList sl = m_filter.split( " ", QString::SkipEmptyParts );
QStringList sl = filterRegExp().pattern().split( " ", QString::SkipEmptyParts );
bool found = true;
foreach( const QString& s, sl )
{
QString album;
if ( !pi->result()->album().isNull() )
album = pi->result()->album()->name();
if ( !pi->result()->track().contains( s, Qt::CaseInsensitive ) &&
!album.contains( s, Qt::CaseInsensitive ) &&
!pi->result()->album()->artist()->name().contains( s, Qt::CaseInsensitive ) )
if ( !textForItem( pi ).contains( s, Qt::CaseInsensitive ) )
{
return false;
found = false;
}
}
return true;
return found;
}
@@ -355,7 +241,7 @@ TreeProxyModel::textForItem( TreeModelItem* item ) const
{
if ( !item )
return QString();
if ( !item->artist().isNull() )
{
return item->artist()->name();

View File

@@ -26,8 +26,6 @@
#include "dllmacro.h"
class DatabaseCommand_AllArtists;
class DLLEXPORT TreeProxyModel : public QSortFilterProxyModel, public Tomahawk::PlaylistInterface
{
Q_OBJECT
@@ -56,7 +54,6 @@ public:
virtual Tomahawk::result_ptr siblingItem( int direction );
virtual Tomahawk::result_ptr siblingItem( int direction, bool readOnly );
virtual QString filter() const { return filterRegExp().pattern(); }
virtual void setFilter( const QString& pattern );
virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; }
@@ -73,8 +70,6 @@ signals:
void sourceTrackCountChanged( unsigned int tracks );
void filterChanged( const QString& filter );
void filteringStarted();
void filteringFinished();
void nextTrackReady();
@@ -86,24 +81,11 @@ protected:
bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
private slots:
void onRowsInserted( const QModelIndex& parent, int start, int end );
void onFilterArtists( const QList<Tomahawk::artist_ptr>& artists );
void onFilterAlbums( const QList<Tomahawk::album_ptr>& albums );
private:
void filterFinished();
QString textForItem( TreeModelItem* item ) const;
mutable QMap< QPersistentModelIndex, Tomahawk::result_ptr > m_cache;
QList<Tomahawk::artist_ptr> m_artistsFilter;
QList<Tomahawk::album_ptr> m_albumsFilter;
DatabaseCommand_AllArtists* m_artistsFilterCmd;
QString m_filter;
TreeModel* m_model;
RepeatMode m_repeatMode;
bool m_shuffled;

View File

@@ -0,0 +1,153 @@
#include "dropmenu.h"
#include <QVBoxLayout>
#include <QLabel>
#include <QDragEnterEvent>
DropMenu::DropMenu( QWidget *parent )
: QWidget( parent )
{
setLayout( new QHBoxLayout() );
layout()->setSpacing( 0 );
}
void
DropMenu::addEntry( DropMenuEntry *entry, bool isDefault )
{
layout()->addWidget( entry );
if( m_entries.isEmpty() || isDefault )
m_activeEntry = entry;
m_entries.append( entry );
connect( entry, SIGNAL( mouseEntered( DropMenuEntry* ) ), this, SLOT( entryHovered( DropMenuEntry* ) ) );
connect( entry, SIGNAL( mouseLeft( DropMenuEntry* ) ), this, SLOT( entryLeft(DropMenuEntry*) ) );
connect( entry, SIGNAL( dropReceived( QDropEvent* ) ) , this, SIGNAL( dropReceived( QDropEvent* ) ) );
if( isDefault )
m_defaultEntry = entry;
}
void
DropMenu::setFilter(DropJob::DropFlags shownEntries)
{
foreach( DropMenuEntry *entry, m_entries )
{
if( ( entry->dropFlags() & shownEntries ) != DropJob::DropFlagsNone )
entry->setVisible( true );
else
entry->setVisible( false );
}
}
bool
DropMenu::hovered() const
{
foreach( DropMenuEntry *entry, m_entries )
{
if( entry->hovered() )
return true;
}
return false;
}
DropMenuEntry*
DropMenu::activeEntry()
{
return m_activeEntry;
}
void
DropMenu::entryHovered( DropMenuEntry *entry )
{
m_activeEntry->setActive( false );
m_activeEntry = entry;
entry->setActive( true );
}
void
DropMenu::entryLeft( DropMenuEntry *entry )
{
entry->setActive( false );
m_defaultEntry->setActive( true );
m_activeEntry = m_defaultEntry;
emit mouseLeft();
}
DropMenuEntry::DropMenuEntry( const QPixmap &icon, const QString &text, DropJob::DropFlags flags, QWidget *parent )
: QWidget( parent )
, m_hovered( false )
, m_flags( flags )
{
QVBoxLayout *layout = new QVBoxLayout();
QLabel* image = new QLabel;
image->setAlignment( Qt::AlignHCenter );
image->setPixmap( icon );
layout->addWidget( image );
m_label = new QLabel( text );
m_label->setAlignment( Qt::AlignHCenter );
layout->addWidget( m_label );
setLayout( layout );
setAcceptDrops( true );
setMouseTracking( true );
}
void
DropMenuEntry::dragEnterEvent( QDragEnterEvent *event )
{
event->acceptProposedAction();
emit mouseEntered( this );
m_hovered = true;
}
void
DropMenuEntry::dragLeaveEvent( QDragLeaveEvent *event )
{
emit mouseLeft( this );
m_hovered = false;
}
void
DropMenuEntry::setActive( bool active )
{
QFont font = m_label->font();
font.setBold( active );
m_label->setFont( font );
}
void
DropMenuEntry::dropEvent( QDropEvent *event )
{
emit dropReceived( event );
m_hovered = false;
}
bool
DropMenuEntry::hovered() const
{
return m_hovered;
}
DropJob::DropFlags
DropMenuEntry::dropFlags() const
{
return m_flags;
}

View File

@@ -0,0 +1,73 @@
#ifndef DROPMENU_H
#define DROPMENU_H
#include "dllmacro.h"
#include "dropjob.h"
#include <QWidget>
#include <QLabel>
class DropMenuEntry;
class DLLEXPORT DropMenu: public QWidget
{
Q_OBJECT
public:
/** @brief Create a DropMenu with the given default flags if an invalid/empty area is hovered */
explicit DropMenu( QWidget *parent = 0 );
void addEntry( DropMenuEntry *entry, bool isDefault = false );
void setFilter( DropJob::DropFlags shownEntries );
/** @brief Returns true if the mouse is somewhere over the contained entries */
bool hovered() const;
DropMenuEntry *activeEntry();
signals:
void dropReceived( QDropEvent *event );
void mouseLeft();
private slots:
void entryHovered( DropMenuEntry* entry );
void entryLeft( DropMenuEntry* entry );
private:
QList< DropMenuEntry* > m_entries;
DropJob::DropFlags m_defaultFlags;
DropMenuEntry *m_defaultEntry;
DropMenuEntry *m_activeEntry;
};
class DLLEXPORT DropMenuEntry : public QWidget
{
Q_OBJECT
public:
explicit DropMenuEntry( const QPixmap &icon, const QString &text, DropJob::DropFlags flags, QWidget *parent = 0 );
void setActive( bool active );
bool hovered() const;
DropJob::DropFlags dropFlags() const;
signals:
void dropReceived( QDropEvent *event );
void mouseEntered( DropMenuEntry *entry );
void mouseLeft( DropMenuEntry *entry );
public slots:
protected:
virtual void dragEnterEvent( QDragEnterEvent *event );
virtual void dragLeaveEvent( QDragLeaveEvent *event );
virtual void dropEvent( QDropEvent *event );
private:
bool m_hovered;
QLabel *m_label;
DropJob::DropFlags m_flags;
};
#endif // DROPMENU_H

View File

@@ -23,7 +23,6 @@
#include <QFontMetrics>
#include <QApplication>
#include <QRect>
#include <QTextLayout>
#include "utils/logger.h"
@@ -38,7 +37,7 @@ ElidedLabel::ElidedLabel( QWidget* parent, Qt::WindowFlags flags )
ElidedLabel::ElidedLabel( const QString& text, QWidget* parent, Qt::WindowFlags flags )
: QFrame( parent, flags )
{
init( text );
init(text);
}
@@ -131,8 +130,6 @@ ElidedLabel::init( const QString& txt )
m_align = Qt::AlignLeft;
m_mode = Qt::ElideMiddle;
m_margin = 0;
m_multiLine = false;
setContentsMargins( 0, 0, 0, 0 );
}
@@ -179,35 +176,8 @@ ElidedLabel::paintEvent( QPaintEvent* event )
QRect r = contentsRect();
r.adjust( m_margin, m_margin, -m_margin, -m_margin );
if ( m_multiLine )
{
QTextLayout textLayout( m_text );
textLayout.setFont( p.font() );
int widthUsed = 0;
int lineCount = 0;
int lineLimit = r.height() / fontMetrics().height();
textLayout.beginLayout();
while ( ++lineCount < lineLimit )
{
QTextLine line = textLayout.createLine();
if ( !line.isValid() )
break;
line.setLineWidth( r.width() );
widthUsed += line.naturalTextWidth();
}
textLayout.endLayout();
widthUsed += r.width();
const QString elidedText = fontMetrics().elidedText( m_text, Qt::ElideRight, widthUsed );
p.drawText( r, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, elidedText );
}
else
{
const QString elidedText = fontMetrics().elidedText( m_text, m_mode, r.width() );
p.drawText( r, m_align, elidedText );
}
const QString elidedText = fontMetrics().elidedText( m_text, m_mode, r.width() );
p.drawText( r, m_align, elidedText );
}

View File

@@ -57,7 +57,6 @@ public:
public slots:
void setText( const QString& text );
void setWordWrap( bool b ) { m_multiLine = b; }
signals:
void clicked();
@@ -75,7 +74,6 @@ private:
Qt::Alignment m_align;
Qt::TextElideMode m_mode;
int m_margin;
bool m_multiLine;
};
#endif // ELIDEDLABEL_H

View File

@@ -27,7 +27,7 @@
#include "artist.h"
#include "album.h"
#include "query.h"
#include "utils/tomahawkutils.h"
#include "tomahawkutils.h"
#include "utils/logger.h"
#define BOXMARGIN 2

View File

@@ -174,13 +174,6 @@ appLogDir()
}
QString
sqlEscape( QString sql )
{
return sql.replace( "'", "''" );
}
QString
timeToString( int seconds )
{

View File

@@ -75,7 +75,6 @@ namespace TomahawkUtils
DLLEXPORT QDir appDataDir();
DLLEXPORT QDir appLogDir();
DLLEXPORT QString sqlEscape( QString sql );
DLLEXPORT QString timeToString( int seconds );
DLLEXPORT QString ageToString( const QDateTime& time );
DLLEXPORT QString filesizeToString( unsigned int size );

View File

@@ -23,6 +23,7 @@
#include "audio/audioengine.h"
#include "context/ContextWidget.h"
#include "utils/animatedsplitter.h"
#include "infobar/infobar.h"
#include "topbar/topbar.h"
@@ -48,7 +49,6 @@
#include "widgets/infowidgets/ArtistInfoWidget.h"
#include "widgets/infowidgets/AlbumInfoWidget.h"
#include "widgets/newplaylistwidget.h"
#include "widgets/animatedsplitter.h"
#include "utils/logger.h"
@@ -76,14 +76,28 @@ ViewManager::ViewManager( QObject* parent )
s_instance = this;
m_widget->setLayout( new QVBoxLayout() );
// m_topbar = new TopBar();
m_infobar = new InfoBar();
m_stack = new QStackedWidget();
/* m_splitter = new AnimatedSplitter();
m_splitter->setOrientation( Qt::Vertical );
m_splitter->setChildrenCollapsible( false );
m_splitter->setGreedyWidget( 0 );
m_splitter->addWidget( m_stack );*/
// m_splitter->addWidget( m_queueView );
// m_splitter->hide( 1, false );
m_contextWidget = new ContextWidget();
m_widget->layout()->addWidget( m_infobar );
// m_widget->layout()->addWidget( m_topbar );
// m_widget->layout()->addWidget( m_splitter );
m_widget->layout()->addWidget( m_stack );
m_widget->layout()->addWidget( m_contextWidget );
// m_widget->layout()->addWidget( m_queueButton );
m_superCollectionView = new ArtistView();
m_superCollectionModel = new TreeModel( m_superCollectionView );
@@ -108,10 +122,11 @@ ViewManager::ViewManager( QObject* parent )
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistInterfaceChanged( Tomahawk::PlaylistInterface* ) ) );
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
connect( m_infobar, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
/* connect( m_infobar, SIGNAL( flatMode() ), SLOT( setTableMode() ) );
connect( m_infobar, SIGNAL( artistMode() ), SLOT( setTreeMode() ) );
connect( m_infobar, SIGNAL( albumMode() ), SLOT( setAlbumMode() ) );*/
/* connect( m_topbar, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
connect( m_topbar, SIGNAL( flatMode() ), SLOT( setTableMode() ) );
connect( m_topbar, SIGNAL( artistMode() ), SLOT( setTreeMode() ) );
connect( m_topbar, SIGNAL( albumMode() ), SLOT( setAlbumMode() ) );*/
}
@@ -246,10 +261,13 @@ ViewManager::show( const Tomahawk::collection_ptr& collection )
if ( !m_collectionViews.contains( collection ) || m_collectionViews.value( collection ).isNull() )
{
view = new CollectionView();
view->setTrackModel( flatModelForCollection( collection ) );
CollectionFlatModel* model = new CollectionFlatModel();
view->setTrackModel( model );
view->setFrameShape( QFrame::NoFrame );
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
model->addCollection( collection );
m_collectionViews.insert( collection, view );
}
else
@@ -267,10 +285,13 @@ ViewManager::show( const Tomahawk::collection_ptr& collection )
if ( !m_treeViews.contains( collection ) || m_treeViews.value( collection ).isNull() )
{
view = new ArtistView();
view->setTreeModel( treeModelForCollection( collection ) );
TreeModel* model = new TreeModel();
view->setTreeModel( model );
view->setFrameShape( QFrame::NoFrame );
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
model->addCollection( collection );
m_treeViews.insert( collection, view );
}
else
@@ -288,9 +309,11 @@ ViewManager::show( const Tomahawk::collection_ptr& collection )
if ( !m_collectionAlbumViews.contains( collection ) || m_collectionAlbumViews.value( collection ).isNull() )
{
aview = new AlbumView();
aview->setAlbumModel( albumModelForCollection( collection ) );
AlbumModel* amodel = new AlbumModel( aview );
aview->setAlbumModel( amodel );
aview->setFrameShape( QFrame::NoFrame );
aview->setAttribute( Qt::WA_MacShowFocusRect, 0 );
amodel->addCollection( collection );
m_collectionAlbumViews.insert( collection, aview );
}
@@ -622,7 +645,7 @@ ViewManager::updateView()
connect( currentPlaylistInterface()->object(), SIGNAL( shuffleModeChanged( bool ) ),
SIGNAL( shuffleModeChanged( bool ) ) );
m_infobar->setFilter( currentPlaylistInterface()->filter() );
// m_topbar->setFilter( currentPlaylistInterface()->filter() );
}
if ( currentPage()->showStatsBar() && currentPlaylistInterface() )
@@ -856,69 +879,6 @@ ViewManager::collectionForInterface( Tomahawk::PlaylistInterface* interface ) co
}
CollectionFlatModel*
ViewManager::flatModelForCollection( const collection_ptr& collection )
{
CollectionFlatModel* model = 0;
if ( !m_collectionFlatModels.contains( collection ) || m_collectionFlatModels.value( collection ).isNull() )
{
model = new CollectionFlatModel();
model->addCollection( collection );
m_collectionFlatModels.insert( collection, QWeakPointer<CollectionFlatModel>( model ) );
}
else
{
model = m_collectionFlatModels.value( collection ).data();
}
return model;
}
TreeModel*
ViewManager::treeModelForCollection( const collection_ptr& collection )
{
TreeModel* model = 0;
if ( !m_collectionTreeModels.contains( collection ) || m_collectionTreeModels.value( collection ).isNull() )
{
model = new TreeModel();
model->addCollection( collection );
m_collectionTreeModels.insert( collection, QWeakPointer<TreeModel>( model ) );
}
else
{
model = m_collectionTreeModels.value( collection ).data();
}
return model;
}
AlbumModel*
ViewManager::albumModelForCollection( const collection_ptr& collection )
{
AlbumModel* model = 0;
if ( !m_collectionAlbumModels.contains( collection ) || m_collectionAlbumModels.value( collection ).isNull() )
{
model = new AlbumModel();
model->addCollection( collection );
m_collectionAlbumModels.insert( collection, QWeakPointer<AlbumModel>( model ) );
}
else
{
model = m_collectionAlbumModels.value( collection ).data();
}
return model;
}
bool
ViewManager::isSuperCollectionVisible() const
{

View File

@@ -104,12 +104,6 @@ public:
// linked to the sidebar. call it right after creating the playlist
PlaylistView* createPageForPlaylist( const Tomahawk::playlist_ptr& pl );
// outsource to a modelManager (?)
CollectionFlatModel* flatModelForCollection( const Tomahawk::collection_ptr& collection );
TreeModel* treeModelForCollection( const Tomahawk::collection_ptr& collection );
AlbumModel* albumModelForCollection( const Tomahawk::collection_ptr& collection );
signals:
void numSourcesChanged( unsigned int sources );
void numTracksChanged( unsigned int tracks );
@@ -208,11 +202,6 @@ private:
QHash< Tomahawk::playlist_ptr, QWeakPointer<PlaylistView> > m_playlistViews;
QHash< Tomahawk::source_ptr, QWeakPointer<SourceInfoWidget> > m_sourceViews;
QHash< Tomahawk::collection_ptr, QWeakPointer<CollectionFlatModel> > m_collectionFlatModels;
QHash< Tomahawk::collection_ptr, QWeakPointer<TreeModel> > m_collectionTreeModels;
QHash< Tomahawk::collection_ptr, QWeakPointer<AlbumModel> > m_collectionAlbumModels;
QList<Tomahawk::ViewPage*> m_pageHistory;
Tomahawk::collection_ptr m_currentCollection;

View File

@@ -308,7 +308,6 @@ void BreadcrumbBar::currentChangedTriggered(QModelIndex const& index)
{
Q_ASSERT(m_selectionModel);
m_selectionModel->setCurrentIndex( index, QItemSelectionModel::SelectCurrent);
emit currentIndexChanged(index);
}
void BreadcrumbBar::resizeEvent ( QResizeEvent * event )

View File

@@ -131,7 +131,6 @@ public:
signals:
void rootClicked();
void currentIndexChanged(QModelIndex);
protected:
/**

View File

@@ -142,9 +142,6 @@ void SiblingCrumbButton::comboboxActivated(int i)
if( count > 0 ) {
qDebug() << "activated" << activated.child(0,0).data().toString();
breadcrumbBar()->currentChangedTriggered(activated.child(0,0));
} else {
// if it has no children, then emit itself
breadcrumbBar()->currentChangedTriggered(activated);
}
}

View File

@@ -71,7 +71,9 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
ui->playlistWidget->setItemDelegate( new PlaylistDelegate() );
ui->playlistWidget->setModel( model );
ui->playlistWidget->overlay()->resize( 380, 86 );
#ifdef Q_OS_MAC
ui->playlistWidget->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
#endif
connect( model, SIGNAL( emptinessChanged( bool) ), this, SLOT( updatePlaylists() ) );

View File

@@ -53,10 +53,10 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent )
ui->setupUi( this );
TomahawkUtils::unmarginLayout( layout() );
TomahawkUtils::unmarginLayout( ui->stackLeft->layout() );
TomahawkUtils::unmarginLayout( ui->horizontalLayout->layout() );
TomahawkUtils::unmarginLayout( ui->horizontalLayout_2->layout() );
TomahawkUtils::unmarginLayout( ui->verticalLayout->layout() );
TomahawkUtils::unmarginLayout( ui->verticalLayout_2->layout() );
TomahawkUtils::unmarginLayout( ui->breadCrumbLeft->layout() );
TomahawkUtils::unmarginLayout( ui->breadCrumbRight->layout() );
//set crumb widgets
@@ -70,42 +70,41 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent )
//ui->breadCrumbLeft->setSelectionModel(selectionModelLeft);
ui->breadCrumbLeft->setUseAnimation(true);
connect(ui->breadCrumbLeft, SIGNAL(currentIndexChanged(QModelIndex)), SLOT(leftCrumbIndexChanged(QModelIndex)));
/*ui->breadCrumbRight->setButtonFactory(crumbFactory);
ui->breadCrumbRight->setButtonFactory(crumbFactory);
ui->breadCrumbRight->setRootIcon(QIcon( RESPATH "images/charts.png" ));
ui->breadCrumbRight->setModel(m_crumbModelLeft);
ui->breadCrumbRight->setUseAnimation(true);*/
ui->breadCrumbRight->setUseAnimation(true);
m_tracksModel = new PlaylistModel( ui->tracksViewLeft );
m_tracksModel = new PlaylistModel( ui->tracksView );
m_tracksModel->setStyle( TrackModel::Short );
ui->tracksViewLeft->setFrameShape( QFrame::NoFrame );
ui->tracksViewLeft->setAttribute( Qt::WA_MacShowFocusRect, 0 );
ui->tracksViewLeft->overlay()->setEnabled( false );
ui->tracksViewLeft->setTrackModel( m_tracksModel );
ui->tracksViewLeft->setHeaderHidden( true );
ui->tracksViewLeft->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->tracksView->setFrameShape( QFrame::NoFrame );
ui->tracksView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
ui->tracksView->overlay()->setEnabled( false );
ui->tracksView->setTrackModel( m_tracksModel );
ui->tracksView->setHeaderHidden( true );
ui->tracksView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
m_artistsModel = new TreeModel( this );
m_artistsModel = new TreeModel( ui->artistsView );
m_artistsModel->setColumnStyle( TreeModel::TrackOnly );
m_artistsProxy = new TreeProxyModel( ui->artistsViewLeft );
m_artistsProxy = new TreeProxyModel( ui->artistsView );
m_artistsProxy->setFilterCaseSensitivity( Qt::CaseInsensitive );
m_artistsProxy->setDynamicSortFilter( true );
ui->artistsViewLeft->setProxyModel( m_artistsProxy );
ui->artistsViewLeft->setTreeModel( m_artistsModel );
ui->artistsViewLeft->setFrameShape( QFrame::NoFrame );
ui->artistsViewLeft->setAttribute( Qt::WA_MacShowFocusRect, 0 );
ui->artistsView->setProxyModel( m_artistsProxy );
ui->artistsView->setTreeModel( m_artistsModel );
ui->artistsView->setFrameShape( QFrame::NoFrame );
ui->artistsView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
m_artistsProxy->sort( -1 ); // disable sorting, must be called after artistsViewLeft->setTreeModel
m_artistsProxy->sort( -1 ); // disable sorting, must be called after artistsView->setTreeModel
ui->artistsView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->artistsView->header()->setVisible( false );
ui->artistsViewLeft->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->artistsViewLeft->header()->setVisible( false );
m_timer = new QTimer( this );
connect( m_timer, SIGNAL( timeout() ), SLOT( checkQueries() ) );
@@ -140,7 +139,13 @@ WhatsHotWidget::fetchData()
requestData.type = Tomahawk::InfoSystem::InfoChartCapabilities;
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
tDebug() << "WhatsHot: requested InfoChartCapabilities";
/*requestData.type = Tomahawk::InfoSystem::InfoChartArtists;
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
requestData.type = Tomahawk::InfoSystem::InfoChartTracks;
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
*/
tDebug() << "WhatsHot: requested InfoChartArtists+Tracks";
}
@@ -157,6 +162,7 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
{
if ( requestData.caller != s_whatsHotIdentifier )
{
// tDebug() << "Info of wrong type or not with our identifier";
return;
}
@@ -178,39 +184,31 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
}
KBreadcrumbSelectionModel *selectionModelLeft = new KBreadcrumbSelectionModel(new QItemSelectionModel(m_crumbModelLeft, this), this);
ui->breadCrumbLeft->setSelectionModel(selectionModelLeft);
//ui->breadCrumbRight->setSelectionModel(selectionModelLeft);
ui->breadCrumbRight->setSelectionModel(selectionModelLeft);
//HACK ALERT - we want the second crumb to expand right away, so we
//force it here. We should find a more elegant want to do this
ui->breadCrumbLeft->currentChangedTriggered(m_crumbModelLeft->index(0,0).child(0,0));
break;
}
case InfoSystem::InfoChart:
case InfoSystem::InfoChartArtists:
{
if( !returnedData.contains("type") )
break;
const QString type = returnedData["type"].toString();
if( !returnedData.contains(type) )
break;
const QString side = requestData.customData["whatshot_side"].toString();
tDebug() << "WhatsHot: got chart! " << type << " on " << side;
if( type == "artists" ) {
setLeftViewArtists();
const QStringList artists = returnedData["artists"].toStringList();
tDebug() << "WhatsHot: got artists! " << artists.size();
m_artistsModel->clear();
foreach ( const QString& artist, artists )
m_artistsModel->addArtists( Artist::get( artist ) );
} else if( type == "tracks" ) {
setLeftViewTracks();
const QList<Tomahawk::InfoSystem::ArtistTrackPair> tracks = returnedData["tracks"].value<QList<Tomahawk::InfoSystem::ArtistTrackPair> >();
tDebug() << "WhatsHot: got tracks! " << tracks.size();
m_tracksModel->clear();
foreach ( const Tomahawk::InfoSystem::ArtistTrackPair& track, tracks ) {
query_ptr query = Query::get( track.artist, track.track, QString(), uuid() );
m_tracksModel->append( query );
}
} else {
tDebug() << "WhatsHot: got unknown chart type" << type;
const QStringList artists = returnedData["artists"].toStringList();
tDebug() << "WhatsHot: got artists! " << artists.size();
tDebug() << artists;
foreach ( const QString& artist, artists )
{
m_artistsModel->addArtists( Artist::get( artist ) );
}
break;
}
case InfoSystem::InfoChartTracks:
{
const QList<Tomahawk::InfoSystem::ArtistTrackPair> tracks = returnedData["tracks"].value<QList<Tomahawk::InfoSystem::ArtistTrackPair> >();
tDebug() << "WhatsHot: got tracks! " << tracks.size();
foreach ( const Tomahawk::InfoSystem::ArtistTrackPair& track, tracks )
{
query_ptr query = Query::get( track.artist, track.track, QString(), uuid() );
m_tracksModel->append( query );
}
break;
}
@@ -227,33 +225,6 @@ WhatsHotWidget::infoSystemFinished( QString target )
}
void
WhatsHotWidget::leftCrumbIndexChanged( QModelIndex index )
{
qDebug() << "WhatsHot:: left crumb changed" << index.data();
QStandardItem* item = m_crumbModelLeft->itemFromIndex(index);
if( !item )
return;
if( !item->data().isValid() )
return;
const QString chartId = item->data().toString();
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria.insert("chart_id", chartId);
Tomahawk::InfoSystem::InfoRequestData requestData;
QVariantMap customData;
customData.insert("whatshot_side", "left");
requestData.caller = s_whatsHotIdentifier;
requestData.customData = customData;
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( criteria );
requestData.type = Tomahawk::InfoSystem::InfoChart;
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
}
void
WhatsHotWidget::changeEvent( QEvent* e )
{
@@ -274,16 +245,9 @@ QStandardItem*
WhatsHotWidget::parseNode(QStandardItem* parentItem, const QString &label, const QVariant &data)
{
tDebug() << "WhatsHot:: parsing " << label;
QStandardItem *sourceItem = new QStandardItem(label);
if( data.canConvert<QList<Tomahawk::InfoSystem::Chart> >() ) {
QList<Tomahawk::InfoSystem::Chart> charts = data.value<QList<Tomahawk::InfoSystem::Chart> >();
foreach( Tomahawk::InfoSystem::Chart chart, charts) {
QStandardItem *childItem= new QStandardItem(chart.label);
childItem->setData(chart.id);
sourceItem->appendRow(childItem);
}
} else if( data.canConvert<QVariantMap>() ) {
if( data.canConvert<QVariantMap>() ) {
QVariantMap dataMap = data.toMap();
foreach(const QString childLabel,dataMap.keys()) {
QStandardItem *childItem = parseNode( sourceItem, childLabel, dataMap[childLabel] );
@@ -302,15 +266,3 @@ WhatsHotWidget::parseNode(QStandardItem* parentItem, const QString &label, const
}
return sourceItem;
}
void
WhatsHotWidget::setLeftViewArtists()
{
ui->stackLeft->setCurrentIndex(1);
}
void
WhatsHotWidget::setLeftViewTracks()
{
ui->stackLeft->setCurrentIndex(0);
}

View File

@@ -81,11 +81,8 @@ private slots:
void checkQueries();
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString target );
void leftCrumbIndexChanged( QModelIndex );
private:
void setLeftViewArtists();
void setLeftViewTracks();
QStandardItem* parseNode(QStandardItem* parentItem, const QString &label, const QVariant &data);
Ui::WhatsHotWidget *ui;

View File

@@ -10,41 +10,42 @@
<height>513</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="HeaderBreadCrumb" name="breadCrumbLeft" native="true"/>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="HeaderBreadCrumb" name="breadCrumbLeft">
</widget>
</item>
<item>
<widget class="PlaylistView" name="tracksView">
<property name="minimumSize">
<size>
<width>320</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="stackLeft">
<widget class="QWidget" name="page">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="PlaylistView" name="tracksViewLeft">
<property name="minimumSize">
<size>
<width>320</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="ArtistView" name="artistsViewLeft">
<property name="minimumSize">
<size>
<width>320</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="HeaderBreadCrumb" name="breadCrumbRight">
</widget>
</item>
<item>
<widget class="ArtistView" name="artistsView">
<property name="minimumSize">
<size>
<width>320</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>

View File

@@ -18,7 +18,7 @@
#include "tomahawkapp.h"
#include "thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.h"
#include "kdsingleapplicationguard/kdsingleapplicationguard.h"
#include <QTranslator>
@@ -42,10 +42,6 @@ main( int argc, char *argv[] )
AEInstallEventHandler( 'GURL', 'GURL', h, 0, false );
#endif
#ifdef TOUCHMAHAWK
QApplication::setGraphicsSystem( "raster" );
#endif
TomahawkApp a( argc, argv );
KDSingleApplicationGuard guard( &a, KDSingleApplicationGuard::AutoKillOtherInstances );
QObject::connect( &guard, SIGNAL( instanceStarted( KDSingleApplicationGuard::Instance ) ), &a, SLOT( instanceStarted( KDSingleApplicationGuard::Instance ) ) );

View File

@@ -30,8 +30,6 @@
#include "utils/logger.h"
#include "dropjob.h"
#include "tomahawkdesktopwindow.h"
using namespace Tomahawk;
@@ -80,7 +78,7 @@ CategoryAddItem::activate()
break;
}
case SourcesModel::StationsCategory:
APP->desktopWindow()->createStation();
APP->mainWindow()->createStation();
break;
}
}
@@ -102,7 +100,7 @@ CategoryAddItem::dialogClosed( int ret )
} else if ( playlistSelectorDlg->playlistTypeIsAuto() && ret ) {
// create Auto Playlist
APP->desktopWindow()->createAutomaticPlaylist( playlistName );
APP->mainWindow()->createAutomaticPlaylist( playlistName );
} else if ( !ret ) {
model()->viewPageActivated( ViewManager::instance()->currentPage() );
}
@@ -261,15 +259,14 @@ CategoryAddItem::dropMimeData( const QMimeData* data, Qt::DropAction )
if ( dropType() == DropTypeLocalItems )
{
dj->setGetWholeArtists( true );
dj->tracksFromMimeData( data, false, true );
dj->setOnlyLocal( true );
}
else if ( dropType() == DropTypeTop50 )
{
dj->setGetWholeArtists( true );
dj->tracksFromMimeData( data, false, false, true );
dj->setGetTop10( true );
}
else
dj->tracksFromMimeData( data, false, false );
dj->tracksFromMimeData( data );
return true;
}
@@ -283,7 +280,7 @@ CategoryAddItem::parsedDroppedTracks( const QList< query_ptr >& tracks )
ViewManager::instance()->show( newpl );
// Give a shot to try to rename it. The playlist has to be created first. ugly.
QTimer::singleShot( 300, APP->desktopWindow()->sourceTreeView(), SLOT( renamePlaylist() ) );
QTimer::singleShot( 300, APP->mainWindow()->sourceTreeView(), SLOT( renamePlaylist() ) );
} else if( m_categoryType == SourcesModel::StationsCategory ) {
// seed the playlist with these song filters
QString name = tracks.isEmpty() ? tr( "New Station" ) : tr( "%1 Station" ).arg( tracks.first()->track() );
@@ -302,7 +299,7 @@ CategoryAddItem::parsedDroppedTracks( const QList< query_ptr >& tracks )
ViewManager::instance()->show( newpl );
// Give a shot to try to rename it. The playlist has to be created first. ugly.
QTimer::singleShot( 300, APP->desktopWindow()->sourceTreeView(), SLOT( renamePlaylist() ) );
QTimer::singleShot( 300, APP->mainWindow()->sourceTreeView(), SLOT( renamePlaylist() ) );
}
}

View File

@@ -183,15 +183,12 @@ PlaylistItem::dropMimeData( const QMimeData* data, Qt::DropAction action )
if ( dropType() == DropTypeLocalItems )
{
dj->setGetWholeArtists( true );
dj->tracksFromMimeData( data, false, true );
dj->setOnlyLocal( true );
}
else if ( dropType() == DropTypeTop50 )
{
dj->setGetWholeArtists( true );
dj->tracksFromMimeData( data, false, false, true );
}
else
dj->tracksFromMimeData( data, false, false );
dj->setGetTop10( true );
dj->tracksFromMimeData( data);
// TODO cant' know if it works or not yet...
return true;

View File

@@ -55,10 +55,6 @@ SourcesModel::SourcesModel( QObject* parent )
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
connect( SourceList::instance(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceRemoved( Tomahawk::source_ptr ) ) );
connect( ViewManager::instance(), SIGNAL( viewPageActivated( Tomahawk::ViewPage* ) ), this, SLOT( viewPageActivated( Tomahawk::ViewPage* ) ) );
QHash<int, QByteArray> roles;
roles[Qt::DisplayRole] = "name";
setRoleNames(roles);
}

View File

@@ -48,7 +48,7 @@
using namespace Tomahawk;
SourceTreeView::SourceTreeView( QWidget* parent, SourcesModel* model )
SourceTreeView::SourceTreeView( QWidget* parent )
: QTreeView( parent )
, m_dragging( false )
{
@@ -85,7 +85,7 @@ SourceTreeView::SourceTreeView( QWidget* parent, SourcesModel* model )
setContextMenuPolicy( Qt::CustomContextMenu );
connect( this, SIGNAL( customContextMenuRequested( QPoint ) ), SLOT( onCustomContextMenu( QPoint ) ) );
m_model = model;
m_model = new SourcesModel( this );
m_proxyModel = new SourcesProxyModel( m_model, this );
connect( m_proxyModel, SIGNAL( selectRequest( QPersistentModelIndex ) ), this, SLOT( selectRequest( QPersistentModelIndex ) ) );
connect( m_proxyModel, SIGNAL( expandRequest( QPersistentModelIndex ) ), this, SLOT( expandRequest( QPersistentModelIndex ) ) );

View File

@@ -37,7 +37,7 @@ class SourceTreeView : public QTreeView
Q_OBJECT
public:
explicit SourceTreeView( QWidget* parent = 0, SourcesModel* model = 0 );
explicit SourceTreeView( QWidget* parent = 0 );
public slots:
void showOfflineSources( bool offlineSourcesShown );

View File

@@ -64,15 +64,11 @@
#include "config.h"
#ifndef TOMAHAWK_HEADLESS
#include "tomahawkdesktopwindow.h"
#include "tomahawkwindow.h"
#include "settingsdialog.h"
#include <QMessageBox>
#endif
#ifdef TOUCHMAHAWK
#include "active/tomahawktouchwindow.h"
#endif
// should go to a plugin actually
#ifdef GLOOX_FOUND
#include "xmppbot/xmppbot.h"
@@ -223,17 +219,10 @@ TomahawkApp::init()
if ( !m_headless )
{
tDebug() << "Init MainWindow.";
m_mainwindow = new TomahawkDesktopWindow();
m_mainwindow = new TomahawkWindow();
m_mainwindow->setWindowTitle( "Tomahawk" );
m_mainwindow->setObjectName( "TH_Main_Window" );
#ifndef TOUCHMAHAWK
m_mainwindow->show();
#else
m_declarativeWindow = new TomahawkTouchWindow();
m_declarativeWindow->show();
#endif // TOUCHMAHAWK
}
#endif
@@ -339,20 +328,6 @@ TomahawkApp::audioControls()
{
return m_mainwindow->audioControls();
}
TomahawkWindow*
TomahawkApp::mainWindow() const
{
// why does static_casdt<TomahawkWindow*> not work here?!
return (TomahawkWindow*) ( m_mainwindow );
}
TomahawkDesktopWindow*
TomahawkApp::desktopWindow() const
{
return m_mainwindow;
}
#endif
@@ -416,8 +391,6 @@ TomahawkApp::registerMetaTypes()
qRegisterMetaType< DirLister::Mode >("DirLister::Mode");
qRegisterMetaType< Tomahawk::InfoSystem::ArtistTrackPair >("Tomahawk::InfoSystem::ArtistTrackPair");
qRegisterMetaType< QList<Tomahawk::InfoSystem::ArtistTrackPair> >("QList<Tomahawk::InfoSystem::ArtistTrackPair>");
qRegisterMetaType< Tomahawk::InfoSystem::Chart>("Tomahawk::InfoSystem::Chart");
qRegisterMetaType< QList<Tomahawk::InfoSystem::Chart> >("QList<Tomahawk::InfoSystem::Chart>");
qRegisterMetaType< QPersistentModelIndex >( "QPersistentModelIndex" );
}

View File

@@ -41,7 +41,7 @@
#include "network/servent.h"
#include "utils/tomahawkutils.h"
#include "thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.h"
#include "kdsingleapplicationguard/kdsingleapplicationguard.h"
class AudioEngine;
class Database;
@@ -65,12 +65,7 @@ namespace Tomahawk
#endif
#ifndef TOMAHAWK_HEADLESS
class TomahawkDesktopWindow;
class AudioControls;
#endif
#ifdef TOUCHMAHAWK
class TomahawkTouchWindow;
class TomahawkWindow;
#endif
@@ -92,12 +87,7 @@ public:
#ifndef TOMAHAWK_HEADLESS
AudioControls* audioControls();
TomahawkWindow* mainWindow() const;
TomahawkDesktopWindow* desktopWindow() const;
#endif
#ifdef TOUCHMAHAWK
TomahawkTouchWindow* declarativeWindow() const { return m_declarativeWindow; }
TomahawkWindow* mainWindow() const { return m_mainwindow; }
#endif
void enableScriptResolver( const QString& scriptPath );
@@ -146,11 +136,7 @@ private:
#endif
#ifndef TOMAHAWK_HEADLESS
TomahawkDesktopWindow* m_mainwindow;
#endif
#ifdef TOUCHMAHAWK
TomahawkTouchWindow* m_declarativeWindow;
TomahawkWindow* m_mainwindow;
#endif
bool m_headless;

View File

@@ -1,599 +0,0 @@
/* === 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 "tomahawkdesktopwindow.h"
#include "ui_tomahawkdesktopwindow.h"
#include <QAction>
#include <QCloseEvent>
#include <QShowEvent>
#include <QHideEvent>
#include <QInputDialog>
#include <QPixmap>
#include <QPropertyAnimation>
#include <QLineEdit>
#include <QMessageBox>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QTimer>
#include <QToolBar>
#include "playlist.h"
#include "query.h"
#include "artist.h"
#include "audio/audioengine.h"
#include "viewmanager.h"
#include "sip/SipHandler.h"
#include "sourcetree/sourcetreeview.h"
#include "widgets/animatedsplitter.h"
#include "utils/proxystyle.h"
#include "utils/widgetdragfilter.h"
#include "utils/xspfloader.h"
#include "widgets/newplaylistwidget.h"
#include "widgets/searchwidget.h"
#include "widgets/playlisttypeselectordlg.h"
#include "audiocontrols.h"
#include "settingsdialog.h"
#include "diagnosticsdialog.h"
#include "tomahawksettings.h"
#include "sourcelist.h"
#include "PipelineStatusView.h"
#include "transferview.h"
#include "tomahawktrayicon.h"
#include "playlist/dynamic/GeneratorInterface.h"
#include "scanmanager.h"
#include "tomahawkapp.h"
#ifdef Q_OS_WIN32
#include <qtsparkle/Updater>
#endif
#include "utils/logger.h"
#include "thirdparty/Qocoa/qsearchfield.h"
using namespace Tomahawk;
TomahawkDesktopWindow::TomahawkDesktopWindow( QWidget* parent )
: TomahawkWindow( parent )
, ui( new Ui::TomahawkDesktopWindow )
, m_searchWidget( 0 )
, m_audioControls( new AudioControls( this ) )
{
connect( ViewManager::instance(), SIGNAL( showQueueRequested() ), SLOT( showQueue() ) );
connect( ViewManager::instance(), SIGNAL( hideQueueRequested() ), SLOT( hideQueue() ) );
ui->setupUi( this );
applyPlatformTweaks();
ui->centralWidget->setContentsMargins( 0, 0, 0, 0 );
TomahawkUtils::unmarginLayout( ui->centralWidget->layout() );
setupSideBar();
statusBar()->addPermanentWidget( m_audioControls, 1 );
setupUpdateCheck();
loadSettings();
setupSignals();
// set initial state
onSipDisconnected();
ViewManager::instance()->setQueue( m_queueView );
ViewManager::instance()->showWelcomePage();
}
TomahawkDesktopWindow::~TomahawkDesktopWindow()
{
delete ui;
}
void
TomahawkDesktopWindow::retranslateUi()
{
ui->retranslateUi( this );
}
void
TomahawkDesktopWindow::loadSettings()
{
TomahawkSettings* s = TomahawkSettings::instance();
if ( !s->mainWindowSplitterState().isEmpty() )
ui->splitter->restoreState( s->mainWindowSplitterState() );
TomahawkWindow::loadSettings();
}
void
TomahawkDesktopWindow::saveSettings()
{
TomahawkSettings* s = TomahawkSettings::instance();
s->setMainWindowSplitterState( ui->splitter->saveState() );
TomahawkWindow::saveSettings();
}
void
TomahawkDesktopWindow::applyPlatformTweaks()
{
// HACK QtCurve causes an infinite loop on startup. This is because setStyle calls setPalette, which calls ensureBaseStyle,
// which loads QtCurve. QtCurve calls setPalette, which creates an infinite loop. The UI will look like CRAP with QtCurve, but
// the user is asking for it explicitly... so he's gonna be stuck with an ugly UI.
if ( !QString( qApp->style()->metaObject()->className() ).toLower().contains( "qtcurve" ) )
qApp->setStyle( new ProxyStyle() );
#ifdef Q_OS_MAC
setUnifiedTitleAndToolBarOnMac( true );
delete ui->hline1;
delete ui->hline2;
#else
ui->hline1->setStyleSheet( "border: 1px solid gray;" );
ui->hline2->setStyleSheet( "border: 1px solid gray;" );
#endif
}
void
TomahawkDesktopWindow::setupSideBar()
{
// Delete fake designer widgets
delete ui->sidebarWidget;
delete ui->playlistWidget;
QWidget* sidebarWidget = new QWidget();
sidebarWidget->setLayout( new QVBoxLayout() );
m_sidebar = new AnimatedSplitter();
m_sidebar->setOrientation( Qt::Vertical );
m_sidebar->setChildrenCollapsible( false );
m_searchWidget = new QSearchField( m_sidebar );
m_searchWidget->setPlaceholderText( "Global Search..." );
connect( m_searchWidget, SIGNAL( returnPressed() ), this, SLOT( onFilterEdited() ) );
m_sourcetree = new SourceTreeView( this, s_sourcesModel );
TransferView* transferView = new TransferView( m_sidebar );
PipelineStatusView* pipelineView = new PipelineStatusView( m_sidebar );
m_queueView = new QueueView( m_sidebar );
m_queueModel = new PlaylistModel( m_queueView );
m_queueModel->setStyle( PlaylistModel::Short );
m_queueView->queue()->setPlaylistModel( m_queueModel );
m_queueView->queue()->playlistModel()->setReadOnly( false );
AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel() );
m_sidebar->addWidget( m_searchWidget );
m_sidebar->addWidget( m_sourcetree );
m_sidebar->addWidget( transferView );
m_sidebar->addWidget( pipelineView );
m_sidebar->addWidget( m_queueView );
m_sidebar->setGreedyWidget( 1 );
m_sidebar->hide( 1, false );
m_sidebar->hide( 2, false );
m_sidebar->hide( 3, false );
m_sidebar->hide( 4, false );
sidebarWidget->layout()->addWidget( m_sidebar );
sidebarWidget->setContentsMargins( 0, 0, 0, 0 );
sidebarWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
sidebarWidget->layout()->setMargin( 0 );
#ifndef Q_OS_MAC
sidebarWidget->layout()->setSpacing( 0 );
#endif
ui->splitter->addWidget( sidebarWidget );
ui->splitter->addWidget( ViewManager::instance()->widget() );
ui->splitter->setStretchFactor( 0, 1 );
ui->splitter->setStretchFactor( 1, 3 );
ui->splitter->setCollapsible( 1, false );
ui->splitter->setHandleWidth( 1 );
ui->actionShowOfflineSources->setChecked( TomahawkSettings::instance()->showOfflineSources() );
}
void
TomahawkDesktopWindow::setupUpdateCheck()
{
#ifndef Q_WS_MAC
ui->menu_Help->insertSeparator( ui->actionAboutTomahawk );
#endif
#if defined( Q_OS_DARWIN ) && defined( HAVE_SPARKLE )
QAction* checkForUpdates = ui->menu_Help->addAction( tr( "Check For Updates..." ) );
checkForUpdates->setMenuRole( QAction::ApplicationSpecificRole );
connect( checkForUpdates, SIGNAL( triggered( bool ) ), SLOT( checkForUpdates() ) );
#elif defined( WIN32 )
QUrl updaterUrl;
if ( qApp->arguments().contains( "--debug" ) )
updaterUrl.setUrl( "http://download.tomahawk-player.org/sparklewin-debug" );
else
updaterUrl.setUrl( "http://download.tomahawk-player.org/sparklewin" );
qtsparkle::Updater* updater = new qtsparkle::Updater( updaterUrl, this );
Q_ASSERT( TomahawkUtils::nam() != 0 );
updater->SetNetworkAccessManager( TomahawkUtils::nam() );
updater->SetVersion( TomahawkUtils::appFriendlyVersion() );
ui->menu_Help->addSeparator();
QAction* checkForUpdates = ui->menu_Help->addAction( tr( "Check For Updates..." ) );
connect( checkForUpdates, SIGNAL( triggered() ), updater, SLOT( CheckNow() ) );
#endif
}
void
TomahawkDesktopWindow::setupSignals()
{
// <From PlaylistManager>
connect( ViewManager::instance(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
m_audioControls, SLOT( onRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
connect( ViewManager::instance(), SIGNAL( shuffleModeChanged( bool ) ),
m_audioControls, SLOT( onShuffleModeChanged( bool ) ) );
// <From AudioEngine>
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( audioStarted() ) );
connect( AudioEngine::instance(), SIGNAL( resumed()), SLOT( audioStarted() ) );
connect( AudioEngine::instance(), SIGNAL( paused() ), SLOT( audioStopped() ) );
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( audioStopped() ) );
// <Menu Items>
// connect( ui->actionAddPeerManually, SIGNAL( triggered() ), SLOT( addPeerManually() ) );
connect( ui->actionPreferences, SIGNAL( triggered() ), SLOT( showSettingsDialog() ) );
connect( ui->actionDiagnostics, SIGNAL( triggered() ), SLOT( showDiagnosticsDialog() ) );
connect( ui->actionToggleConnect, SIGNAL( triggered() ), SipHandler::instance(), SLOT( toggleConnect() ) );
connect( ui->actionUpdateCollection, SIGNAL( triggered() ), SLOT( updateCollectionManually() ) );
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( rescanCollectionManually() ) );
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
connect( ui->actionCreate_New_Station, SIGNAL( triggered() ), SLOT( createStation() ));
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
connect( ui->actionExit, SIGNAL( triggered() ), qApp, SLOT( quit() ) );
connect( ui->actionShowOfflineSources, SIGNAL( triggered() ), SLOT( showOfflineSources() ) );
connect( ui->actionPlay, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( playPause() ) );
connect( ui->actionNext, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( next() ) );
connect( ui->actionPrevious, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( previous() ) );
#if defined( Q_WS_MAC )
connect( ui->actionMinimize, SIGNAL( triggered() ), SLOT( minimize() ) );
connect( ui->actionZoom, SIGNAL( triggered() ), SLOT( maximize() ) );
#else
ui->menuWindow->clear();
ui->menuWindow->menuAction()->setVisible( false );
#endif
// <SipHandler>
connect( SipHandler::instance(), SIGNAL( connected( SipPlugin* ) ), SLOT( onSipConnected() ) );
connect( SipHandler::instance(), SIGNAL( disconnected( SipPlugin* ) ), SLOT( onSipDisconnected() ) );
connect( SipHandler::instance(), SIGNAL( authError( SipPlugin* ) ), SLOT( onSipError() ) );
// <SipMenu>
connect( SipHandler::instance(), SIGNAL( pluginAdded( SipPlugin* ) ), this, SLOT( onSipPluginAdded( SipPlugin* ) ) );
connect( SipHandler::instance(), SIGNAL( pluginRemoved( SipPlugin* ) ), this, SLOT( onSipPluginRemoved( SipPlugin* ) ) );
foreach( SipPlugin *plugin, SipHandler::instance()->allPlugins() )
{
connect( plugin, SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
connect( plugin, SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
}
}
void
TomahawkDesktopWindow::showSettingsDialog()
{
qDebug() << Q_FUNC_INFO;
SettingsDialog win;
win.exec();
}
void TomahawkDesktopWindow::showDiagnosticsDialog()
{
qDebug() << Q_FUNC_INFO;
DiagnosticsDialog win;
win.exec();
}
void
TomahawkDesktopWindow::updateCollectionManually()
{
if ( TomahawkSettings::instance()->hasScannerPaths() )
ScanManager::instance()->runScan();
}
void
TomahawkDesktopWindow::rescanCollectionManually()
{
if ( TomahawkSettings::instance()->hasScannerPaths() )
ScanManager::instance()->runScan( true );
}
void
TomahawkDesktopWindow::addPeerManually()
{
TomahawkSettings* s = TomahawkSettings::instance();
bool ok;
QString addr = QInputDialog::getText( this, tr( "Connect To Peer" ),
tr( "Enter peer address:" ), QLineEdit::Normal,
s->value( "connip" ).toString(), &ok ); // FIXME
if ( !ok )
return;
s->setValue( "connip", addr );
QString ports = QInputDialog::getText( this, tr( "Connect To Peer" ),
tr( "Enter peer port:" ), QLineEdit::Normal,
s->value( "connport", "50210" ).toString(), &ok );
if ( !ok )
return;
s->setValue( "connport", ports );
int port = ports.toInt();
QString key = QInputDialog::getText( this, tr( "Connect To Peer" ),
tr( "Enter peer key:" ), QLineEdit::Normal,
"whitelist", &ok );
if ( !ok )
return;
qDebug() << "Attempting to connect to" << addr;
Servent::instance()->connectToPeer( addr, port, key );
}
void
TomahawkDesktopWindow::pluginMenuAdded( QMenu* menu )
{
ui->menuNetwork->addMenu( menu );
}
void
TomahawkDesktopWindow::pluginMenuRemoved( QMenu* menu )
{
foreach( QAction* action, ui->menuNetwork->actions() )
{
if( action->menu() == menu )
{
ui->menuNetwork->removeAction( action );
return;
}
}
}
void
TomahawkDesktopWindow::showOfflineSources()
{
m_sourcetree->showOfflineSources( ui->actionShowOfflineSources->isChecked() );
TomahawkSettings::instance()->setShowOfflineSources( ui->actionShowOfflineSources->isChecked() );
}
void
TomahawkDesktopWindow::loadSpiff()
{
bool ok;
QString urlstr = QInputDialog::getText( this, tr( "Load XSPF" ), tr( "Path:" ), QLineEdit::Normal, "http://ws.audioscrobbler.com/1.0/tag/metal/toptracks.xspf", &ok );
if ( !ok || urlstr.isEmpty() )
return;
XSPFLoader* loader = new XSPFLoader;
loader->load( QUrl::fromUserInput( urlstr ) );
}
void
TomahawkDesktopWindow::createAutomaticPlaylist( QString playlistName )
{
QString name = playlistName;
if ( name.isEmpty() )
return;
source_ptr author = SourceList::instance()->getLocal();
QString id = uuid();
QString info = ""; // FIXME
QString creator = "someone"; // FIXME
dynplaylist_ptr playlist = DynamicPlaylist::create( author, id, name, info, creator, Static, false );
playlist->setMode( Static );
playlist->createNewRevision( uuid(), playlist->currentrevision(), playlist->type(), playlist->generator()->controls(), playlist->entries() );
ViewManager::instance()->show( playlist );
}
void
TomahawkDesktopWindow::createStation()
{
bool ok;
QString name = QInputDialog::getText( this, tr( "Create New Station" ), tr( "Name:" ), QLineEdit::Normal, tr( "New Station" ), &ok );
if ( !ok || name.isEmpty() )
return;
source_ptr author = SourceList::instance()->getLocal();
QString id = uuid();
QString info = ""; // FIXME
QString creator = "someone"; // FIXME
dynplaylist_ptr playlist = DynamicPlaylist::create( author, id, name, info, creator, OnDemand, false );
playlist->setMode( OnDemand );
playlist->createNewRevision( uuid(), playlist->currentrevision(), playlist->type(), playlist->generator()->controls() );
ViewManager::instance()->show( playlist );
}
void
TomahawkDesktopWindow::createPlaylist()
{
PlaylistTypeSelectorDlg* playlistSelectorDlg = new PlaylistTypeSelectorDlg( TomahawkApp::instance()->mainWindow(), Qt::Sheet );
#ifndef Q_OS_MAC
playlistSelectorDlg->setModal( true );
#endif
connect( playlistSelectorDlg, SIGNAL( finished( int ) ), this, SLOT( playlistCreateDialogFinished( int ) ) );
playlistSelectorDlg->show();
}
void TomahawkDesktopWindow::playlistCreateDialogFinished( int ret )
{
PlaylistTypeSelectorDlg* playlistSelectorDlg = qobject_cast< PlaylistTypeSelectorDlg* >( sender() );
Q_ASSERT( playlistSelectorDlg );
QString playlistName = playlistSelectorDlg->playlistName();
if ( playlistName.isEmpty() )
playlistName = tr( "New Playlist" );
if ( !playlistSelectorDlg->playlistTypeIsAuto() && ret ) {
playlist_ptr playlist = Tomahawk::Playlist::create( SourceList::instance()->getLocal(), uuid(), playlistName, "", "", false, QList< query_ptr>() );
ViewManager::instance()->show( playlist );
} else if ( playlistSelectorDlg->playlistTypeIsAuto() && ret ) {
// create Auto Playlist
createAutomaticPlaylist( playlistName );
}
playlistSelectorDlg->deleteLater();
}
void
TomahawkDesktopWindow::audioStarted()
{
ui->actionPlay->setText( tr( "Pause" ) );
}
void
TomahawkDesktopWindow::audioStopped()
{
ui->actionPlay->setText( tr( "Play" ) );
}
void
TomahawkDesktopWindow::onSipConnected()
{
ui->actionToggleConnect->setText( tr( "Go &offline" ) );
}
void
TomahawkDesktopWindow::onSipDisconnected()
{
ui->actionToggleConnect->setText( tr( "Go &online" ) );
}
void
TomahawkDesktopWindow::onSipPluginAdded( SipPlugin* p )
{
connect( p, SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
connect( p, SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
}
void
TomahawkDesktopWindow::onSipPluginRemoved( SipPlugin* p )
{
Q_UNUSED( p );
}
void
TomahawkDesktopWindow::onSipError()
{
onSipDisconnected();
QMessageBox::warning( this,
tr( "Authentication Error" ),
QString( "Error connecting to SIP: Authentication failed!" ),
QMessageBox::Ok );
}
void
TomahawkDesktopWindow::showAboutTomahawk()
{
QMessageBox::about( this, tr( "About Tomahawk" ),
tr( "<h2><b>Tomahawk %1<br/>(%2)</h2>Copyright 2010, 2011<br/>Christian Muehlhaeuser &lt;muesli@tomahawk-player.org&gt;<br/><br/>"
"Thanks to: Leo Franchi, Jeff Mitchell, Dominik Schmidt, Jason Herskowitz, Alejandro Wainzinger, Michael Zanetti, Harald Sitter and Steve Robertson" )
.arg( TomahawkUtils::appFriendlyVersion() )
.arg( qApp->applicationVersion() ) );
}
void
TomahawkDesktopWindow::checkForUpdates()
{
#ifdef Q_WS_MAC
Tomahawk::checkForUpdates();
#endif
}
void
TomahawkDesktopWindow::onSearch( const QString& search )
{
if ( !search.trimmed().isEmpty() )
ViewManager::instance()->show( new SearchWidget( search, this ) );
}
void
TomahawkDesktopWindow::onFilterEdited()
{
onSearch( m_searchWidget->text() );
m_searchWidget->clear();
}
void
TomahawkDesktopWindow::showQueue()
{
if ( QThread::currentThread() != thread() )
{
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
QMetaObject::invokeMethod( this, "showQueue", Qt::QueuedConnection );
return;
}
m_queueView->show();
}
void
TomahawkDesktopWindow::hideQueue()
{
if ( QThread::currentThread() != thread() )
{
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
QMetaObject::invokeMethod( this, "hideQueue", Qt::QueuedConnection );
return;
}
m_queueView->hide();
}

View File

@@ -1,120 +0,0 @@
/* === 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 TOMAHAWKDESKTOPWINDOW_H
#define TOMAHAWKDESKTOPWINDOW_H
#include "result.h"
#include "tomahawkwindow.h"
#include <QMainWindow>
#include <QVariantMap>
#include <QPushButton>
#include <QString>
#include <QStackedWidget>
class QSearchField;
class SipPlugin;
class SourceTreeView;
class QAction;
class MusicScanner;
class AudioControls;
class TomahawkTrayIcon;
class PlaylistModel;
class QueueView;
class AnimatedSplitter;
namespace Ui
{
class TomahawkDesktopWindow;
class GlobalSearchWidget;
}
class TomahawkDesktopWindow : public TomahawkWindow
{
Q_OBJECT
public:
TomahawkDesktopWindow( QWidget* parent = 0 );
~TomahawkDesktopWindow();
AudioControls* audioControls() { return m_audioControls; }
SourceTreeView* sourceTreeView() const { return m_sourcetree; }
protected:
virtual void retranslateUi();
public slots:
void createAutomaticPlaylist( QString );
void createStation();
void createPlaylist();
void loadSpiff();
void showSettingsDialog();
void showDiagnosticsDialog();
void updateCollectionManually();
void rescanCollectionManually();
void pluginMenuAdded(QMenu*);
void pluginMenuRemoved(QMenu*);
void showOfflineSources();
private slots:
void onSipConnected();
void onSipDisconnected();
void onSipError();
void addPeerManually();
void audioStarted();
void audioStopped();
void showAboutTomahawk();
void checkForUpdates();
void onSipPluginAdded( SipPlugin* p );
void onSipPluginRemoved( SipPlugin* p );
void onSearch( const QString& search );
void onFilterEdited();
void showQueue();
void hideQueue();
void playlistCreateDialogFinished( int ret );
private:
virtual void loadSettings();
virtual void saveSettings();
void applyPlatformTweaks();
void setupSignals();
void setupSideBar();
void setupUpdateCheck();
Ui::TomahawkDesktopWindow* ui;
QSearchField* m_searchWidget;
AudioControls* m_audioControls;
SourceTreeView* m_sourcetree;
QPushButton* m_statusButton;
QPushButton* m_queueButton;
PlaylistModel* m_queueModel;
QueueView* m_queueView;
AnimatedSplitter* m_sidebar;
};
#endif // TOMAHAWKDESKTOPWINDOW_H

View File

@@ -1,267 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TomahawkDesktopWindow</class>
<widget class="QMainWindow" name="TomahawkDesktopWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1000</width>
<height>660</height>
</rect>
</property>
<property name="windowTitle">
<string>Tomahawk</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="hline1">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="handleWidth">
<number>1</number>
</property>
<widget class="QWidget" name="sidebarWidget" native="true"/>
<widget class="QWidget" name="playlistWidget" native="true"/>
</widget>
</item>
<item>
<widget class="QFrame" name="hline2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1000</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuSettings">
<property name="title">
<string>&amp;Settings</string>
</property>
<addaction name="actionPreferences"/>
</widget>
<widget class="QMenu" name="menuApp">
<property name="title">
<string>&amp;Music Player</string>
</property>
<addaction name="actionPlay"/>
<addaction name="actionPrevious"/>
<addaction name="actionNext"/>
<addaction name="separator"/>
<addaction name="actionUpdateCollection"/>
<addaction name="actionRescanCollection"/>
<addaction name="separator"/>
<addaction name="actionShowOfflineSources"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuNetwork">
<property name="title">
<string>&amp;Network</string>
</property>
<addaction name="actionToggleConnect"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menuWindow">
<property name="title">
<string>&amp;Window</string>
</property>
<addaction name="actionMinimize"/>
<addaction name="actionZoom"/>
</widget>
<widget class="QMenu" name="menu_Help">
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="actionDiagnostics"/>
<addaction name="actionAboutTomahawk"/>
</widget>
<widget class="QMenu" name="menuPlaylist">
<property name="title">
<string>&amp;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"/>
<addaction name="menuSettings"/>
<addaction name="menuWindow"/>
<addaction name="menu_Help"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionExit">
<property name="text">
<string>&amp;Quit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
<property name="menuRole">
<enum>QAction::QuitRole</enum>
</property>
</action>
<action name="actionToggleConnect">
<property name="text">
<string>Go &amp;Online</string>
</property>
</action>
<action name="actionAddFriendManually">
<property name="text">
<string>Add &amp;Friend...</string>
</property>
</action>
<action name="actionUpdateCollection">
<property name="text">
<string>U&amp;pdate Collection</string>
</property>
<property name="toolTip">
<string>Update Collection</string>
</property>
</action>
<action name="actionPreferences">
<property name="text">
<string>&amp;Configure Tomahawk...</string>
</property>
<property name="menuRole">
<enum>QAction::PreferencesRole</enum>
</property>
</action>
<action name="actionLoadXSPF">
<property name="text">
<string>Load &amp;XSPF...</string>
</property>
</action>
<action name="actionCreatePlaylist">
<property name="text">
<string>Create &amp;New Playlist...</string>
</property>
</action>
<action name="actionAboutTomahawk">
<property name="text">
<string>About &amp;Tomahawk...</string>
</property>
<property name="menuRole">
<enum>QAction::AboutRole</enum>
</property>
</action>
<action name="actionCreateAutomaticPlaylist">
<property name="text">
<string>Create New &amp;Automatic Playlist</string>
</property>
</action>
<action name="actionCreate_New_Station">
<property name="text">
<string>Create New &amp;Station</string>
</property>
</action>
<action name="actionShowOfflineSources">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Show Offline Sources</string>
</property>
</action>
<action name="actionHideOfflineSources">
<property name="text">
<string>Hide Offline Sources</string>
</property>
</action>
<action name="actionMinimize">
<property name="text">
<string>Minimize</string>
</property>
<property name="shortcut">
<string>Ctrl+M</string>
</property>
</action>
<action name="actionZoom">
<property name="text">
<string>Zoom</string>
</property>
<property name="shortcut">
<string>Meta+Ctrl+Z</string>
</property>
</action>
<action name="actionDiagnostics">
<property name="text">
<string>Diagnostics...</string>
</property>
<property name="menuRole">
<enum>QAction::ApplicationSpecificRole</enum>
</property>
</action>
<action name="actionRescanCollection">
<property name="text">
<string>Fully &amp;Rescan Collection</string>
</property>
<property name="toolTip">
<string>Fully Rescan Collection</string>
</property>
</action>
<action name="actionPlay">
<property name="text">
<string>Play</string>
</property>
<property name="shortcut">
<string>Space</string>
</property>
</action>
<action name="actionPrevious">
<property name="text">
<string>Previous</string>
</property>
</action>
<action name="actionNext">
<property name="text">
<string>Next</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
<slots>
<slot>on_btnResolve_clicked()</slot>
</slots>
</ui>

View File

@@ -42,11 +42,6 @@ TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
m_contextMenu = new QMenu();
setContextMenu( m_contextMenu );
#ifdef TOUCHMAHAWK
connect(m_contextMenu->addAction( tr("Show Desktop Gui") ), SIGNAL( triggered() ), parent, SLOT( show() ) );
m_contextMenu->addSeparator();
#endif TOUCHMAHAWK
m_playPauseAction = m_contextMenu->addAction( tr( "Play" ) );
//m_pauseAction = m_contextMenu->addAction( tr( "Pause" ) );
m_stopAction = m_contextMenu->addAction( tr( "Stop" ) );
@@ -184,14 +179,7 @@ TomahawkTrayIcon::onActivated( QSystemTrayIcon::ActivationReason reason )
{
case QSystemTrayIcon::Trigger:
{
QMainWindow* mainwindow = 0;
#ifndef TOUCHMAHAWK
mainwindow = APP->mainWindow();
#else
mainwindow = (QMainWindow*) APP->declarativeWindow();
#endif
TomahawkWindow* mainwindow = APP->mainWindow();
if ( mainwindow->isVisible() )
{
mainwindow->hide();

View File

@@ -17,44 +17,97 @@
*/
#include "tomahawkwindow.h"
#include "ui_tomahawkwindow.h"
#include "artist.h"
#include "tomahawksettings.h"
#include "tomahawktrayicon.h"
#include "tomahawkapp.h"
#include "sourcetree/sourcesmodel.h"
#include "viewmanager.h"
#include "audio/audioengine.h"
#include <QAction>
#include <QCloseEvent>
#include <QShowEvent>
#include <QHideEvent>
#include <QInputDialog>
#include <QPixmap>
#include <QPropertyAnimation>
#include <QLineEdit>
#include <QMessageBox>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QTimer>
#include <QToolBar>
#include "playlist.h"
#include "query.h"
#include "artist.h"
#include "audio/audioengine.h"
#include "viewmanager.h"
#include "sip/SipHandler.h"
#include "sourcetree/sourcetreeview.h"
#include "utils/animatedsplitter.h"
#include "utils/proxystyle.h"
#include "utils/xspfloader.h"
#include "widgets/newplaylistwidget.h"
#include "widgets/searchwidget.h"
#include "widgets/playlisttypeselectordlg.h"
#include "audiocontrols.h"
#include "settingsdialog.h"
#include "diagnosticsdialog.h"
#include "tomahawksettings.h"
#include "sourcelist.h"
#include "PipelineStatusView.h"
#include "transferview.h"
#include "tomahawktrayicon.h"
#include "playlist/dynamic/GeneratorInterface.h"
#include "scanmanager.h"
#include "playlist/queueview.h"
#include "tomahawkapp.h"
#ifdef Q_OS_WIN32
#include <qtsparkle/Updater>
#endif
#include "utils/logger.h"
#include "Qocoa/qsearchfield.h"
using namespace Tomahawk;
SourcesModel* TomahawkWindow::s_sourcesModel = 0;
TomahawkTrayIcon* TomahawkWindow::s_trayIcon = 0;
TomahawkWindow::TomahawkWindow( QWidget* parent )
: QMainWindow( parent )
, ui( new Ui::TomahawkWindow )
, m_searchWidget( 0 )
, m_audioControls( new AudioControls( this ) )
, m_trayIcon( new TomahawkTrayIcon( this ) )
{
setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) );
if( !ViewManager::instance() )
new ViewManager( this );
ViewManager* vm = new ViewManager( this );
connect( vm, SIGNAL( showQueueRequested() ), SLOT( showQueue() ) );
connect( vm, SIGNAL( hideQueueRequested() ), SLOT( hideQueue() ) );
if( !s_sourcesModel )
s_sourcesModel = new SourcesModel( this );
ui->setupUi( this );
applyPlatformTweaks();
if( !s_trayIcon )
s_trayIcon = new TomahawkTrayIcon( this );
ui->centralWidget->setContentsMargins( 0, 0, 0, 0 );
TomahawkUtils::unmarginLayout( ui->centralWidget->layout() );
setupSideBar();
statusBar()->addPermanentWidget( m_audioControls, 1 );
setupUpdateCheck();
loadSettings();
setupSignals();
// set initial state
onSipDisconnected();
vm->setQueue( m_queueView );
vm->showWelcomePage();
}
TomahawkWindow::~TomahawkWindow()
{
saveSettings();
delete ui;
}
@@ -82,6 +135,8 @@ TomahawkWindow::loadSettings()
restoreGeometry( s->mainWindowGeometry() );
if ( !s->mainWindowState().isEmpty() )
restoreState( s->mainWindowState() );
if ( !s->mainWindowSplitterState().isEmpty() )
ui->splitter->restoreState( s->mainWindowSplitterState() );
#ifdef QT_MAC_USE_COCOA
if ( workaround )
@@ -99,6 +154,179 @@ TomahawkWindow::saveSettings()
TomahawkSettings* s = TomahawkSettings::instance();
s->setMainWindowGeometry( saveGeometry() );
s->setMainWindowState( saveState() );
s->setMainWindowSplitterState( ui->splitter->saveState() );
}
void
TomahawkWindow::applyPlatformTweaks()
{
// HACK QtCurve causes an infinite loop on startup. This is because setStyle calls setPalette, which calls ensureBaseStyle,
// which loads QtCurve. QtCurve calls setPalette, which creates an infinite loop. The UI will look like CRAP with QtCurve, but
// the user is asking for it explicitly... so he's gonna be stuck with an ugly UI.
if ( !QString( qApp->style()->metaObject()->className() ).toLower().contains( "qtcurve" ) )
qApp->setStyle( new ProxyStyle() );
#ifdef Q_OS_MAC
setUnifiedTitleAndToolBarOnMac( true );
delete ui->hline1;
delete ui->hline2;
#else
ui->hline1->setStyleSheet( "border: 1px solid gray;" );
ui->hline2->setStyleSheet( "border: 1px solid gray;" );
#endif
}
void
TomahawkWindow::setupSideBar()
{
// Delete fake designer widgets
delete ui->sidebarWidget;
delete ui->playlistWidget;
QWidget* sidebarWidget = new QWidget();
sidebarWidget->setLayout( new QVBoxLayout() );
m_sidebar = new AnimatedSplitter();
m_sidebar->setOrientation( Qt::Vertical );
m_sidebar->setChildrenCollapsible( false );
m_searchWidget = new QSearchField( m_sidebar );
m_searchWidget->setPlaceholderText( "Global Search..." );
connect( m_searchWidget, SIGNAL( returnPressed() ), this, SLOT( onFilterEdited() ) );
m_sourcetree = new SourceTreeView();
TransferView* transferView = new TransferView( m_sidebar );
PipelineStatusView* pipelineView = new PipelineStatusView( m_sidebar );
m_queueView = new QueueView( m_sidebar );
m_queueModel = new PlaylistModel( m_queueView );
m_queueModel->setStyle( PlaylistModel::Short );
m_queueView->queue()->setPlaylistModel( m_queueModel );
m_queueView->queue()->playlistModel()->setReadOnly( false );
AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel() );
m_sidebar->addWidget( m_searchWidget );
m_sidebar->addWidget( m_sourcetree );
m_sidebar->addWidget( transferView );
m_sidebar->addWidget( pipelineView );
m_sidebar->addWidget( m_queueView );
m_sidebar->setGreedyWidget( 1 );
m_sidebar->hide( 1, false );
m_sidebar->hide( 2, false );
m_sidebar->hide( 3, false );
m_sidebar->hide( 4, false );
sidebarWidget->layout()->addWidget( m_sidebar );
sidebarWidget->setContentsMargins( 0, 0, 0, 0 );
sidebarWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
sidebarWidget->layout()->setMargin( 0 );
#ifndef Q_OS_MAC
sidebarWidget->layout()->setSpacing( 0 );
#endif
ui->splitter->addWidget( sidebarWidget );
ui->splitter->addWidget( ViewManager::instance()->widget() );
ui->splitter->setStretchFactor( 0, 1 );
ui->splitter->setStretchFactor( 1, 3 );
ui->splitter->setCollapsible( 1, false );
ui->splitter->setHandleWidth( 1 );
ui->actionShowOfflineSources->setChecked( TomahawkSettings::instance()->showOfflineSources() );
}
void
TomahawkWindow::setupUpdateCheck()
{
#ifndef Q_WS_MAC
ui->menu_Help->insertSeparator( ui->actionAboutTomahawk );
#endif
#if defined( Q_OS_DARWIN ) && defined( HAVE_SPARKLE )
QAction* checkForUpdates = ui->menu_Help->addAction( tr( "Check For Updates..." ) );
checkForUpdates->setMenuRole( QAction::ApplicationSpecificRole );
connect( checkForUpdates, SIGNAL( triggered( bool ) ), SLOT( checkForUpdates() ) );
#elif defined( WIN32 )
QUrl updaterUrl;
if ( qApp->arguments().contains( "--debug" ) )
updaterUrl.setUrl( "http://download.tomahawk-player.org/sparklewin-debug" );
else
updaterUrl.setUrl( "http://download.tomahawk-player.org/sparklewin" );
qtsparkle::Updater* updater = new qtsparkle::Updater( updaterUrl, this );
Q_ASSERT( TomahawkUtils::nam() != 0 );
updater->SetNetworkAccessManager( TomahawkUtils::nam() );
updater->SetVersion( TomahawkUtils::appFriendlyVersion() );
ui->menu_Help->addSeparator();
QAction* checkForUpdates = ui->menu_Help->addAction( tr( "Check For Updates..." ) );
connect( checkForUpdates, SIGNAL( triggered() ), updater, SLOT( CheckNow() ) );
#endif
}
void
TomahawkWindow::setupSignals()
{
// <From PlaylistManager>
connect( ViewManager::instance(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
m_audioControls, SLOT( onRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
connect( ViewManager::instance(), SIGNAL( shuffleModeChanged( bool ) ),
m_audioControls, SLOT( onShuffleModeChanged( bool ) ) );
// <From AudioEngine>
connect( AudioEngine::instance(), SIGNAL( loading( const Tomahawk::result_ptr& ) ),
SLOT( onPlaybackLoading( const Tomahawk::result_ptr& ) ) );
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( audioStarted() ) );
connect( AudioEngine::instance(), SIGNAL( resumed()), SLOT( audioStarted() ) );
connect( AudioEngine::instance(), SIGNAL( paused() ), SLOT( audioStopped() ) );
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( audioStopped() ) );
// <Menu Items>
// connect( ui->actionAddPeerManually, SIGNAL( triggered() ), SLOT( addPeerManually() ) );
connect( ui->actionPreferences, SIGNAL( triggered() ), SLOT( showSettingsDialog() ) );
connect( ui->actionDiagnostics, SIGNAL( triggered() ), SLOT( showDiagnosticsDialog() ) );
connect( ui->actionToggleConnect, SIGNAL( triggered() ), SipHandler::instance(), SLOT( toggleConnect() ) );
connect( ui->actionUpdateCollection, SIGNAL( triggered() ), SLOT( updateCollectionManually() ) );
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( rescanCollectionManually() ) );
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
connect( ui->actionCreate_New_Station, SIGNAL( triggered() ), SLOT( createStation() ));
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
connect( ui->actionExit, SIGNAL( triggered() ), qApp, SLOT( quit() ) );
connect( ui->actionShowOfflineSources, SIGNAL( triggered() ), SLOT( showOfflineSources() ) );
connect( ui->actionPlay, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( playPause() ) );
connect( ui->actionNext, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( next() ) );
connect( ui->actionPrevious, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( previous() ) );
#if defined( Q_OS_DARWIN )
connect( ui->actionMinimize, SIGNAL( triggered() ), SLOT( minimize() ) );
connect( ui->actionZoom, SIGNAL( triggered() ), SLOT( maximize() ) );
#else
ui->menuWindow->clear();
ui->menuWindow->menuAction()->setVisible( false );
#endif
// <SipHandler>
connect( SipHandler::instance(), SIGNAL( connected( SipPlugin* ) ), SLOT( onSipConnected() ) );
connect( SipHandler::instance(), SIGNAL( disconnected( SipPlugin* ) ), SLOT( onSipDisconnected() ) );
connect( SipHandler::instance(), SIGNAL( authError( SipPlugin* ) ), SLOT( onSipError() ) );
// <SipMenu>
connect( SipHandler::instance(), SIGNAL( pluginAdded( SipPlugin* ) ), this, SLOT( onSipPluginAdded( SipPlugin* ) ) );
connect( SipHandler::instance(), SIGNAL( pluginRemoved( SipPlugin* ) ), this, SLOT( onSipPluginRemoved( SipPlugin* ) ) );
foreach( SipPlugin *plugin, SipHandler::instance()->allPlugins() )
{
connect( plugin, SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
connect( plugin, SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
}
}
@@ -110,7 +338,7 @@ TomahawkWindow::changeEvent( QEvent* e )
switch ( e->type() )
{
case QEvent::LanguageChange:
retranslateUi();
ui->retranslateUi( this );
break;
default:
@@ -130,7 +358,7 @@ TomahawkWindow::closeEvent( QCloseEvent* e )
return;
}
#else
s_trayIcon->setShowHideWindow( false );
m_trayIcon->setShowHideWindow( false );
#endif
e->accept();
@@ -160,6 +388,245 @@ TomahawkWindow::hideEvent( QHideEvent* e )
#endif
}
void
TomahawkWindow::showSettingsDialog()
{
qDebug() << Q_FUNC_INFO;
SettingsDialog win;
win.exec();
}
void TomahawkWindow::showDiagnosticsDialog()
{
qDebug() << Q_FUNC_INFO;
DiagnosticsDialog win;
win.exec();
}
void
TomahawkWindow::updateCollectionManually()
{
if ( TomahawkSettings::instance()->hasScannerPaths() )
ScanManager::instance()->runScan();
}
void
TomahawkWindow::rescanCollectionManually()
{
if ( TomahawkSettings::instance()->hasScannerPaths() )
ScanManager::instance()->runScan( true );
}
void
TomahawkWindow::addPeerManually()
{
TomahawkSettings* s = TomahawkSettings::instance();
bool ok;
QString addr = QInputDialog::getText( this, tr( "Connect To Peer" ),
tr( "Enter peer address:" ), QLineEdit::Normal,
s->value( "connip" ).toString(), &ok ); // FIXME
if ( !ok )
return;
s->setValue( "connip", addr );
QString ports = QInputDialog::getText( this, tr( "Connect To Peer" ),
tr( "Enter peer port:" ), QLineEdit::Normal,
s->value( "connport", "50210" ).toString(), &ok );
if ( !ok )
return;
s->setValue( "connport", ports );
int port = ports.toInt();
QString key = QInputDialog::getText( this, tr( "Connect To Peer" ),
tr( "Enter peer key:" ), QLineEdit::Normal,
"whitelist", &ok );
if ( !ok )
return;
qDebug() << "Attempting to connect to" << addr;
Servent::instance()->connectToPeer( addr, port, key );
}
void
TomahawkWindow::pluginMenuAdded( QMenu* menu )
{
ui->menuNetwork->addMenu( menu );
}
void
TomahawkWindow::pluginMenuRemoved( QMenu* menu )
{
foreach( QAction* action, ui->menuNetwork->actions() )
{
if( action->menu() == menu )
{
ui->menuNetwork->removeAction( action );
return;
}
}
}
void
TomahawkWindow::showOfflineSources()
{
m_sourcetree->showOfflineSources( ui->actionShowOfflineSources->isChecked() );
TomahawkSettings::instance()->setShowOfflineSources( ui->actionShowOfflineSources->isChecked() );
}
void
TomahawkWindow::loadSpiff()
{
bool ok;
QString urlstr = QInputDialog::getText( this, tr( "Load XSPF" ), tr( "Path:" ), QLineEdit::Normal, "http://ws.audioscrobbler.com/1.0/tag/metal/toptracks.xspf", &ok );
if ( !ok || urlstr.isEmpty() )
return;
XSPFLoader* loader = new XSPFLoader;
loader->load( QUrl::fromUserInput( urlstr ) );
}
void
TomahawkWindow::createAutomaticPlaylist( QString playlistName )
{
QString name = playlistName;
if ( name.isEmpty() )
return;
source_ptr author = SourceList::instance()->getLocal();
QString id = uuid();
QString info = ""; // FIXME
QString creator = "someone"; // FIXME
dynplaylist_ptr playlist = DynamicPlaylist::create( author, id, name, info, creator, Static, false );
playlist->setMode( Static );
playlist->createNewRevision( uuid(), playlist->currentrevision(), playlist->type(), playlist->generator()->controls(), playlist->entries() );
ViewManager::instance()->show( playlist );
}
void
TomahawkWindow::createStation()
{
bool ok;
QString name = QInputDialog::getText( this, tr( "Create New Station" ), tr( "Name:" ), QLineEdit::Normal, tr( "New Station" ), &ok );
if ( !ok || name.isEmpty() )
return;
source_ptr author = SourceList::instance()->getLocal();
QString id = uuid();
QString info = ""; // FIXME
QString creator = "someone"; // FIXME
dynplaylist_ptr playlist = DynamicPlaylist::create( author, id, name, info, creator, OnDemand, false );
playlist->setMode( OnDemand );
playlist->createNewRevision( uuid(), playlist->currentrevision(), playlist->type(), playlist->generator()->controls() );
ViewManager::instance()->show( playlist );
}
void
TomahawkWindow::createPlaylist()
{
PlaylistTypeSelectorDlg* playlistSelectorDlg = new PlaylistTypeSelectorDlg( TomahawkApp::instance()->mainWindow(), Qt::Sheet );
#ifndef Q_OS_MAC
playlistSelectorDlg->setModal( true );
#endif
connect( playlistSelectorDlg, SIGNAL( finished( int ) ), this, SLOT( playlistCreateDialogFinished( int ) ) );
playlistSelectorDlg->show();
}
void TomahawkWindow::playlistCreateDialogFinished( int ret )
{
PlaylistTypeSelectorDlg* playlistSelectorDlg = qobject_cast< PlaylistTypeSelectorDlg* >( sender() );
Q_ASSERT( playlistSelectorDlg );
QString playlistName = playlistSelectorDlg->playlistName();
if ( playlistName.isEmpty() )
playlistName = tr( "New Playlist" );
if ( !playlistSelectorDlg->playlistTypeIsAuto() && ret ) {
playlist_ptr playlist = Tomahawk::Playlist::create( SourceList::instance()->getLocal(), uuid(), playlistName, "", "", false, QList< query_ptr>() );
ViewManager::instance()->show( playlist );
} else if ( playlistSelectorDlg->playlistTypeIsAuto() && ret ) {
// create Auto Playlist
createAutomaticPlaylist( playlistName );
}
playlistSelectorDlg->deleteLater();
}
void
TomahawkWindow::audioStarted()
{
ui->actionPlay->setText( tr( "Pause" ) );
}
void
TomahawkWindow::audioStopped()
{
ui->actionPlay->setText( tr( "Play" ) );
}
void
TomahawkWindow::onPlaybackLoading( const Tomahawk::result_ptr& result )
{
m_currentTrack = result;
setWindowTitle( m_windowTitle );
}
void
TomahawkWindow::onSipConnected()
{
ui->actionToggleConnect->setText( tr( "Go &offline" ) );
}
void
TomahawkWindow::onSipDisconnected()
{
ui->actionToggleConnect->setText( tr( "Go &online" ) );
}
void
TomahawkWindow::onSipPluginAdded( SipPlugin* p )
{
connect( p, SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
connect( p, SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
}
void
TomahawkWindow::onSipPluginRemoved( SipPlugin* p )
{
Q_UNUSED( p );
}
void
TomahawkWindow::onSipError()
{
onSipDisconnected();
QMessageBox::warning( this,
tr( "Authentication Error" ),
QString( "Error connecting to SIP: Authentication failed!" ),
QMessageBox::Ok );
}
void
TomahawkWindow::setWindowTitle( const QString& title )
{
@@ -175,6 +642,70 @@ TomahawkWindow::setWindowTitle( const QString& title )
}
void
TomahawkWindow::showAboutTomahawk()
{
QMessageBox::about( this, tr( "About Tomahawk" ),
tr( "<h2><b>Tomahawk %1<br/>(%2)</h2>Copyright 2010, 2011<br/>Christian Muehlhaeuser &lt;muesli@tomahawk-player.org&gt;<br/><br/>"
"Thanks to: Leo Franchi, Jeff Mitchell, Dominik Schmidt, Jason Herskowitz, Alejandro Wainzinger, Michael Zanetti, Harald Sitter and Steve Robertson" )
.arg( TomahawkUtils::appFriendlyVersion() )
.arg( qApp->applicationVersion() ) );
}
void
TomahawkWindow::checkForUpdates()
{
#ifdef Q_WS_MAC
Tomahawk::checkForUpdates();
#endif
}
void
TomahawkWindow::onSearch( const QString& search )
{
if ( !search.trimmed().isEmpty() )
ViewManager::instance()->show( new SearchWidget( search, this ) );
}
void
TomahawkWindow::onFilterEdited()
{
onSearch( m_searchWidget->text() );
m_searchWidget->clear();
}
void
TomahawkWindow::showQueue()
{
if ( QThread::currentThread() != thread() )
{
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
QMetaObject::invokeMethod( this, "showQueue", Qt::QueuedConnection );
return;
}
m_queueView->show();
}
void
TomahawkWindow::hideQueue()
{
if ( QThread::currentThread() != thread() )
{
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
QMetaObject::invokeMethod( this, "hideQueue", Qt::QueuedConnection );
return;
}
m_queueView->hide();
}
void
TomahawkWindow::minimize()
{
@@ -201,29 +732,3 @@ TomahawkWindow::maximize()
showMaximized();
}
}
void
TomahawkWindow::onPlaybackLoading( const Tomahawk::result_ptr& result )
{
m_currentTrack = result;
setWindowTitle( m_windowTitle );
}
void
TomahawkWindow::retranslateUi()
{
}
void
TomahawkWindow::setupSignals()
{
// <From AudioEngine>
connect( AudioEngine::instance(), SIGNAL( loading( const Tomahawk::result_ptr& ) ),
SLOT( onPlaybackLoading( const Tomahawk::result_ptr& ) ) );
}

View File

@@ -20,49 +20,113 @@
#define TOMAHAWKWINDOW_H
#include <QMainWindow>
#include <QVariantMap>
#include <QPushButton>
#include <QString>
#include <QStackedWidget>
#include "result.h"
class SourcesModel;
class TomahawkTrayIcon;
class QSearchField;
class SipPlugin;
class SourceTreeView;
class QAction;
class MusicScanner;
class AudioControls;
class TomahawkTrayIcon;
class PlaylistModel;
class QueueView;
class AnimatedSplitter;
namespace Ui
{
class TomahawkWindow;
class GlobalSearchWidget;
}
class TomahawkWindow : public QMainWindow
{
Q_OBJECT
Q_OBJECT
public:
TomahawkWindow( QWidget* parent = 0 );
~TomahawkWindow();
virtual void setWindowTitle( const QString& title );
AudioControls* audioControls() { return m_audioControls; }
SourceTreeView* sourceTreeView() const { return m_sourcetree; }
void setWindowTitle( const QString& title );
protected:
virtual void changeEvent( QEvent* e );
virtual void closeEvent( QCloseEvent* e );
virtual void showEvent( QShowEvent* e );
virtual void hideEvent( QHideEvent* e );
void changeEvent( QEvent* e );
void closeEvent( QCloseEvent* e );
void showEvent( QShowEvent* e );
void hideEvent( QHideEvent* e );
virtual void retranslateUi();
virtual void loadSettings();
virtual void saveSettings();
public slots:
void createAutomaticPlaylist( QString );
void createStation();
void createPlaylist();
void loadSpiff();
void showSettingsDialog();
void showDiagnosticsDialog();
void updateCollectionManually();
void rescanCollectionManually();
void pluginMenuAdded(QMenu*);
void pluginMenuRemoved(QMenu*);
void showOfflineSources();
private slots:
virtual void minimize();
virtual void maximize();
void onSipConnected();
void onSipDisconnected();
void onSipError();
void addPeerManually();
void onPlaybackLoading( const Tomahawk::result_ptr& result );
void audioStarted();
void audioStopped();
void showAboutTomahawk();
void checkForUpdates();
void onSipPluginAdded( SipPlugin* p );
void onSipPluginRemoved( SipPlugin* p );
void onSearch( const QString& search );
void onFilterEdited();
void showQueue();
void hideQueue();
void minimize();
void maximize();
void playlistCreateDialogFinished( int ret );
private:
void loadSettings();
void saveSettings();
void applyPlatformTweaks();
void setupSignals();
void setupSideBar();
void setupUpdateCheck();
protected:
static SourcesModel* s_sourcesModel;
static TomahawkTrayIcon* s_trayIcon;
Ui::TomahawkWindow* ui;
QSearchField* m_searchWidget;
AudioControls* m_audioControls;
TomahawkTrayIcon* m_trayIcon;
SourceTreeView* m_sourcetree;
QPushButton* m_statusButton;
QPushButton* m_queueButton;
PlaylistModel* m_queueModel;
QueueView* m_queueView;
AnimatedSplitter* m_sidebar;
QString m_windowTitle;
Tomahawk::result_ptr m_currentTrack;
QString m_windowTitle;
};
#endif // TOMAHAWKWINDOW_H

View File

@@ -22,7 +22,7 @@
#include <QTreeWidget>
#include "typedefs.h"
#include "widgets/animatedsplitter.h"
#include "utils/animatedsplitter.h"
class StreamConnection;