/src/libtomahawk/widgets/welcomewidget.h

http://github.com/tomahawk-player/tomahawk · C Header · 134 lines · 81 code · 35 blank · 18 comment · 0 complexity · a744dc390555c7ebedc0bcee1790d612 MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  4. * Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
  5. *
  6. * Tomahawk is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Tomahawk is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef WELCOMEWIDGET_H
  20. #define WELCOMEWIDGET_H
  21. #include <QWidget>
  22. #include <QListWidgetItem>
  23. #include <QStyledItemDelegate>
  24. #include "PlaylistInterface.h"
  25. #include "Query.h"
  26. #include "Source.h"
  27. #include "ViewPage.h"
  28. #include "utils/TomahawkUtilsGui.h"
  29. #include "DllMacro.h"
  30. class AlbumModel;
  31. class RecentlyPlayedModel;
  32. class OverlayWidget;
  33. class WelcomeWidgetInterface;
  34. namespace Ui
  35. {
  36. class WelcomeWidget;
  37. }
  38. class DLLEXPORT PlaylistDelegate : public QStyledItemDelegate
  39. {
  40. Q_OBJECT
  41. public:
  42. PlaylistDelegate()
  43. {
  44. m_playlistIcon = QPixmap( RESPATH "images/playlist-icon.png" );
  45. m_autoIcon = QPixmap( RESPATH "images/automatic-playlist.png" );
  46. m_stationIcon = QPixmap( RESPATH "images/station.png" );
  47. m_defaultAvatar = TomahawkUtils::createRoundedImage( QPixmap( RESPATH "images/user-avatar.png" ), QSize( 0, 0 ) );
  48. }
  49. protected:
  50. void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
  51. QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
  52. private:
  53. QPixmap m_playlistIcon, m_autoIcon, m_stationIcon, m_defaultAvatar;
  54. };
  55. class DLLEXPORT PlaylistWidget : public QListView
  56. {
  57. Q_OBJECT
  58. public:
  59. PlaylistWidget( QWidget* parent = 0 );
  60. OverlayWidget* overlay() const { return m_overlay; }
  61. virtual void setModel( QAbstractItemModel* model );
  62. signals:
  63. void modelChanged();
  64. private:
  65. OverlayWidget* m_overlay;
  66. };
  67. class DLLEXPORT WelcomeWidget : public QWidget, public Tomahawk::ViewPage
  68. {
  69. Q_OBJECT
  70. public:
  71. WelcomeWidget( QWidget* parent = 0 );
  72. virtual ~WelcomeWidget();
  73. virtual QWidget* widget() { return this; }
  74. virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
  75. virtual QString title() const { return tr( "Welcome to Tomahawk" ); }
  76. virtual QString description() const { return QString(); }
  77. virtual bool showInfoBar() const { return false; }
  78. virtual bool isBeingPlayed() const;
  79. virtual bool jumpToCurrentTrack();
  80. protected:
  81. void changeEvent( QEvent* e );
  82. signals:
  83. void destroyed( QWidget* widget );
  84. public slots:
  85. void updatePlaylists();
  86. void updateRecentAdditions();
  87. void loadData();
  88. private slots:
  89. void onSourcesReady();
  90. void onSourceAdded( const Tomahawk::source_ptr& source );
  91. void onPlaylistActivated( const QModelIndex& );
  92. private:
  93. Ui::WelcomeWidget *ui;
  94. RecentlyPlayedModel* m_tracksModel;
  95. AlbumModel* m_recentAlbumsModel;
  96. Tomahawk::playlistinterface_ptr m_playlistInterface;
  97. friend class ::WelcomeWidgetInterface;
  98. };
  99. #endif // WELCOMEWIDGET_H