File indexing completed on 2024-05-19 04:50:16

0001 /****************************************************************************************
0002  * Copyright (c) 2007 Shane King <kde@dontletsstart.com>                                *
0003  * Copyright (c) 2013 Vedant Agarwala <vedant.kota@gmail.com>                           *
0004  *                                                                                      *
0005  * This program is free software; you can redistribute it and/or modify it under        *
0006  * the terms of the GNU General Public License as published by the Free Software        *
0007  * Foundation; either version 2 of the License, or (at your option) any later           *
0008  * version.                                                                             *
0009  *                                                                                      *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0013  *                                                                                      *
0014  * You should have received a copy of the GNU General Public License along with         *
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0016  ****************************************************************************************/
0017 
0018 #ifndef LASTFMSERVICESETTINGS_H
0019 #define LASTFMSERVICESETTINGS_H
0020 
0021 #include "LastFmServiceConfig.h"
0022 #include "core/meta/forward_declarations.h" // for using the Meta::LabelList
0023 
0024 #include <kcmodule.h>
0025 
0026 #include <QNetworkReply>
0027 
0028 #include <Auth.h>
0029 
0030 namespace Ui { class LastFmConfigWidget; }
0031 
0032 class LastFmServiceSettings : public KCModule
0033 {
0034     Q_OBJECT
0035 
0036 public:
0037     explicit LastFmServiceSettings( QWidget *parent = nullptr, const QVariantList &args = QVariantList() );
0038 
0039     ~LastFmServiceSettings() override;
0040 
0041     void save() override;
0042     void load() override;
0043     void defaults() override;
0044 
0045 private Q_SLOTS:
0046     void testLogin();
0047     void onAuthenticated();
0048     void onError( QNetworkReply::NetworkError code );
0049     void onConfigUpdated();
0050 
0051 private:
0052     /**
0053      * gets the index of the @param label in the QComboBox
0054      * If the label doesn't exist in the list, its added and then the index is returned
0055      */
0056     int filteredLabelComboIndex( const QString &label );
0057 
0058     Ui::LastFmConfigWidget *m_configDialog;
0059     LastFmServiceConfigPtr m_config;
0060 
0061     QNetworkReply* m_authQuery;
0062 
0063 private Q_SLOTS:
0064     void settingsChanged();
0065     void addNewLabels( const Meta::LabelList &labels );
0066 };
0067 
0068 #endif // LASTFMSERVICESETTINGS_H