File indexing completed on 2025-01-05 04:25:43

0001 /****************************************************************************************
0002  * Copyright (c) 2009-2010 Joffrey Clavel <jclavel@clabert.info>                        *
0003  * Copyright (c) 2009 Oleksandr Khayrullin <saniokh@gmail.com>                          *
0004  * Copyright (c) 2010 Alexandre Mendes <alex.mendes1988@gmail.com>                      *
0005  *                                                                                      *
0006  * This program is free software; you can redistribute it and/or modify it under        *
0007  * the terms of the GNU General Public License as published by the Free Software        *
0008  * Foundation; either version 2 of the License, or (at your option) any later           *
0009  * version.                                                                             *
0010  *                                                                                      *
0011  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0012  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0013  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0014  *                                                                                      *
0015  * You should have received a copy of the GNU General Public License along with         *
0016  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0017  ****************************************************************************************/
0018 
0019 #ifndef SIMILAR_ARTISTS_APPLET_H
0020 #define SIMILAR_ARTISTS_APPLET_H
0021 
0022 
0023 #include "ArtistWidget.h"
0024 #include "SimilarArtist.h"
0025 #include "context/Applet.h"
0026 #include "context/DataEngine.h"
0027 
0028 #include <ui_similarArtistsSettings.h>
0029 
0030 #include <QStack>
0031 
0032 class KConfigDialog;
0033 class QGraphicsLinearLayout;
0034 
0035 namespace Plasma
0036 {
0037 class IconWidget;
0038 }
0039 
0040 /**
0041  * SimilarArtists will display similar artists from the Internet, relative to the current playing artist.
0042  * @author Joffrey Clavel
0043  * @author Oleksandr Khayrullin
0044  * @version 0.1
0045  */
0046 class SimilarArtistsApplet : public Context::Applet
0047 {
0048     Q_OBJECT
0049 
0050 public:
0051 
0052     /**
0053      * SimilarArtistsApplet constructor
0054      * @param parent The widget parent
0055      * @param args   List of strings containing two entries: the service id
0056      *               and the applet id
0057      */
0058     SimilarArtistsApplet( QObject* parent, const QVariantList& args );
0059 
0060     /**
0061      * SimilarArtistsApplet destructor
0062      */
0063     ~SimilarArtistsApplet();
0064 
0065 protected:
0066     void createConfigurationInterface( KConfigDialog *parent );
0067 
0068 public Q_SLOTS:
0069     /**
0070      * Initialization of the applet's display, creation of the layout, scrolls
0071      */
0072     virtual void init();
0073 
0074     /**
0075      * Update the current artist and his similar artists
0076      */
0077     void dataUpdated( const QString &source, const Plasma::DataEngine::Data &data );
0078 
0079 private Q_SLOTS:
0080     void goBackward();
0081     void goForward();
0082     void updateNavigationIcons();
0083     void queryArtist( const QString &name );
0084     void queryForCurrentTrack();
0085 
0086 private:
0087 
0088     /**
0089      * Update the display of the artists according to the lists m_similars
0090      */
0091     void artistsUpdate();
0092 
0093     /**
0094      * This scrollArea contents the artists widgets
0095      */
0096     ArtistsListWidget *m_scroll;
0097 
0098     /**
0099      * The list of similar artists to display
0100      */
0101     SimilarArtist::List m_similars;
0102 
0103     /**
0104      * Artist which you want to see artists like
0105      */
0106     QString m_artist;
0107 
0108     QStack<QString> m_historyBack;
0109     QStack<QString> m_historyForward;
0110     Plasma::IconWidget *m_backwardIcon;
0111     Plasma::IconWidget *m_forwardIcon;
0112     Plasma::IconWidget *m_currentArtistIcon;
0113     Plasma::IconWidget *m_settingsIcon;
0114     QGraphicsLinearLayout *m_layout;
0115     Ui::similarArtistsSettings ui_Settings;
0116 
0117     /**
0118      * The max number artists
0119      */
0120     int m_maxArtists;
0121 
0122 private Q_SLOTS:
0123 
0124     /**
0125      * Allows the connection to the lastfm's api
0126      */
0127     void connectSource( const QString &source );
0128 
0129     /**
0130      * Show the settings windows
0131      */
0132     void configure();
0133     void saveSettings();
0134 
0135     void showSimilarArtists( const QString &name );
0136     void showArtistBio( const QString &name );
0137 };
0138 
0139 AMAROK_EXPORT_APPLET( similarArtists, SimilarArtistsApplet )
0140 
0141 #endif // SIMILARARTISTSAPPLET_H