1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-24 01:39:42 +01:00

Introduce AccountConfigWidget type for handling errors later on

This commit is contained in:
Dominik Schmidt 2013-01-23 19:29:30 +01:00
parent b01544c763
commit 724f92e776
29 changed files with 118 additions and 36 deletions

View File

@ -22,6 +22,7 @@
#include "XmppConfigWidget.h"
#include "sip/SipPlugin.h"
#include "XmppInfoPlugin.h"
#include "accounts/AccountConfigWidget.h"
#include <QtPlugin>
@ -44,7 +45,7 @@ XmppAccount::XmppAccount( const QString &accountId )
setAccountServiceName( "Jabber (XMPP)" );
setTypes( SipType );
m_configWidget = QPointer< QWidget >( new XmppConfigWidget( this, 0 ) );
m_configWidget = QPointer< AccountConfigWidget >( new XmppConfigWidget( this, 0 ) );
m_onlinePixmap = QPixmap( ":/xmpp-icon.png" );
m_offlinePixmap = QPixmap( ":/xmpp-offline-icon.png" );

View File

@ -73,14 +73,14 @@ public:
SipPlugin* sipPlugin();
QWidget* configurationWidget() { return m_configWidget.data(); }
AccountConfigWidget* configurationWidget() { return m_configWidget.data(); }
QWidget* aclWidget() { return 0; }
void saveConfig();
virtual Tomahawk::Accounts::Account::ConnectionState connectionState() const;
protected:
QPointer< QWidget > m_configWidget; // so the google wrapper can change the config dialog a bit
QPointer< AccountConfigWidget > m_configWidget; // so the google wrapper can change the config dialog a bit
QPointer< XmppSipPlugin > m_xmppSipPlugin;
QPointer< Tomahawk::InfoSystem::XmppInfoPlugin > m_xmppInfoPlugin;

View File

@ -34,7 +34,7 @@ namespace Accounts
{
XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent ) :
QWidget( parent ),
AccountConfigWidget( parent ),
m_ui( new Ui::XmppConfigWidget ),
m_account( account )
{

View File

@ -21,7 +21,7 @@
#define JABBERACCOUNTCONFIGWIDGET_H
#include "accounts/AccountDllMacro.h"
#include "accounts/AccountConfigWidget.h"
#include <QWidget>
namespace Ui
@ -39,7 +39,7 @@ class XmppAccount;
class GoogleWrapper;
class ACCOUNTDLLEXPORT XmppConfigWidget : public QWidget
class ACCOUNTDLLEXPORT XmppConfigWidget : public AccountConfigWidget
{
Q_OBJECT

View File

@ -68,7 +68,7 @@ public:
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() { return Tomahawk::InfoSystem::InfoPluginPtr(); }
SipPlugin* sipPlugin();
QWidget* configurationWidget() { return 0; }
AccountConfigWidget* configurationWidget() { return 0; }
QWidget* aclWidget() { return 0; }
private:

View File

@ -201,6 +201,7 @@ list(APPEND libSources
accounts/DelegateConfigWrapper.cpp
accounts/AccountFactoryWrapper.cpp
accounts/AccountFactoryWrapperDelegate.cpp
accounts/AccountConfigWidget.cpp
accounts/spotify/SpotifyAccount.cpp
accounts/spotify/SpotifyAccountConfig.cpp

View File

@ -21,6 +21,7 @@
#include "Source.h"
#include "utils/Logger.h"
#include "accounts/AccountConfigWidget.h"
#include <QMetaProperty>
#include <QBuffer>
@ -28,6 +29,7 @@
#include <QIcon>
#include <QWidget>
#include <QUiLoader>
#include <QBoxLayout>
Tomahawk::ExternalResolverGui::ExternalResolverGui(const QString& filePath)
: Tomahawk::ExternalResolver(filePath)
@ -80,22 +82,29 @@ Tomahawk::ExternalResolverGui::addChildProperties( QObject* widget, QVariantMap&
}
QWidget*
AccountConfigWidget*
Tomahawk::ExternalResolverGui::widgetFromData( QByteArray& data, QWidget* parent )
{
if( data.isEmpty() )
return 0;
AccountConfigWidget* configWidget = new AccountConfigWidget( parent );
QUiLoader l;
QBuffer b( &data );
QWidget* w = l.load( &b, parent );
QWidget* w = l.load( &b, configWidget );
// HACK: proper way would be to create a designer plugin for this widget type
configWidget->setLayout( new QBoxLayout( QBoxLayout::TopToBottom ) );
configWidget->layout()->addWidget( w );
#ifdef Q_OS_MAC
w->setContentsMargins( 12, 12, 12, 12 );
#else
w->setContentsMargins( 6, 6, 6, 6 );
#endif
return w;
return configWidget;
}

View File

@ -25,6 +25,7 @@
#include <QPixmap>
class QWidget;
class AccountConfigWidget;
namespace Tomahawk
{
@ -41,13 +42,13 @@ Q_OBJECT
public:
ExternalResolverGui( const QString& filePath );
virtual QWidget* configUI() const = 0;
virtual AccountConfigWidget* configUI() const = 0;
virtual QPixmap icon() const { return QPixmap(); }
virtual void setIcon( const QPixmap& ) {}
protected:
QWidget* widgetFromData( QByteArray& data, QWidget* parent = 0 );
AccountConfigWidget* widgetFromData( QByteArray& data, QWidget* parent = 0 );
QVariant configMsgFromWidget( QWidget* w );
QByteArray fixDataImagePaths( const QByteArray& data, bool compressed, const QVariantMap& images );

View File

@ -66,7 +66,7 @@ Account::~Account()
#ifndef ENABLE_HEADLESS
QWidget*
AccountConfigWidget*
Account::configurationWidget()
{
return 0;

View File

@ -33,6 +33,7 @@
class SipPlugin;
class AccountConfigWidget;
namespace Tomahawk
{
@ -82,7 +83,7 @@ public:
* Configuration widgets can have a "dataError( bool )" signal to enable/disable the OK button in their wrapper dialogs.
*/
#ifndef ENABLE_HEADLESS
virtual QWidget* configurationWidget() = 0;
virtual AccountConfigWidget* configurationWidget() = 0;
virtual QWidget* aboutWidget() { return 0; }
virtual QWidget* aclWidget() = 0;
virtual QPixmap icon() const = 0;

View File

@ -0,0 +1,24 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2013, 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 "AccountConfigWidget.h"
AccountConfigWidget::AccountConfigWidget(QWidget *parent) :
QWidget(parent)
{
}

View File

@ -0,0 +1,33 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2013, 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 ACCOUNTCONFIGWIDGET_H
#define ACCOUNTCONFIGWIDGET_H
#include "DllMacro.h"
#include <QWidget>
class DLLEXPORT AccountConfigWidget : public QWidget
{
Q_OBJECT
public:
explicit AccountConfigWidget(QWidget *parent = 0);
};
#endif // ACCOUNTCONFIGWIDGET_H

View File

@ -16,10 +16,12 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DelegateConfigWrapper.h"
#include "AccountConfigWidget.h"
#include <QMessageBox>
DelegateConfigWrapper::DelegateConfigWrapper( QWidget* conf, QWidget* aboutWidget, const QString& title, QWidget* parent, Qt::WindowFlags flags )
DelegateConfigWrapper::DelegateConfigWrapper( AccountConfigWidget* conf, QWidget* aboutWidget, const QString& title, QWidget* parent, Qt::WindowFlags flags )
: QDialog( parent, flags )
, m_widget( conf )
, m_aboutW( aboutWidget )

View File

@ -24,11 +24,13 @@
#include <QPushButton>
#include <QDebug>
class AccountConfigWidget;
class DelegateConfigWrapper : public QDialog
{
Q_OBJECT
public:
DelegateConfigWrapper( QWidget* conf, QWidget* aboutWidget, const QString& title, QWidget* parent, Qt::WindowFlags flags = 0 );
DelegateConfigWrapper( AccountConfigWidget* conf, QWidget* aboutWidget, const QString& title, QWidget* parent, Qt::WindowFlags flags = 0 );
~DelegateConfigWrapper() {}
@ -53,7 +55,8 @@ private slots:
private:
QDialogButtonBox* m_buttons;
QWidget* m_widget, *m_aboutW;
AccountConfigWidget* m_widget;
QWidget* m_aboutW;
QPushButton *m_okButton, *m_deleteButton;
bool m_deleted;
};

View File

@ -181,7 +181,7 @@ ResolverAccount::connectionState() const
}
QWidget*
AccountConfigWidget*
ResolverAccount::configurationWidget()
{
if ( m_resolver.isNull() )

View File

@ -71,7 +71,7 @@ public:
virtual bool isAuthenticated() const;
virtual Tomahawk::Accounts::Account::ConnectionState connectionState() const;
virtual QWidget* configurationWidget();
virtual AccountConfigWidget* configurationWidget();
virtual QString errorMessage() const;
virtual void saveConfig();

View File

@ -137,7 +137,7 @@ LastFmAccount::deauthenticate()
}
QWidget*
AccountConfigWidget*
LastFmAccount::configurationWidget()
{
if ( m_configWidget.isNull() )

View File

@ -81,7 +81,7 @@ public:
virtual ConnectionState connectionState() const;
virtual QPixmap icon() const;
virtual QWidget* aclWidget() { return 0; }
virtual QWidget* configurationWidget();
virtual AccountConfigWidget* configurationWidget();
virtual void saveConfig();
QString username() const;

View File

@ -39,7 +39,7 @@ using namespace Tomahawk::Accounts;
LastFmConfig::LastFmConfig( LastFmAccount* account )
: QWidget( 0 )
: AccountConfigWidget( 0 )
, m_account( account )
, m_page( 1 )
, m_lastTimeStamp( 0 )

View File

@ -20,6 +20,7 @@
#define LASTFMCONFIG_H
#include "Query.h"
#include "accounts/AccountConfigWidget.h"
#include "database/DatabaseCommand_LoadSocialActions.h"
#include <QWidget>
@ -34,7 +35,7 @@ namespace Accounts {
class LastFmAccount;
class LastFmConfig : public QWidget
class LastFmConfig : public AccountConfigWidget
{
Q_OBJECT
public:

View File

@ -1110,7 +1110,7 @@ SpotifyAccount::icon() const
}
QWidget*
AccountConfigWidget*
SpotifyAccount::configurationWidget()
{
if ( m_configWidget.isNull() )
@ -1124,7 +1124,7 @@ SpotifyAccount::configurationWidget()
if ( m_spotifyResolver.isNull() || !m_spotifyResolver.data()->running() )
return 0;
return static_cast< QWidget* >( m_configWidget.data() );
return static_cast< AccountConfigWidget* >( m_configWidget.data() );
}

View File

@ -89,7 +89,7 @@ public:
virtual ~SpotifyAccount();
static SpotifyAccount* instance();
virtual QPixmap icon() const;
virtual QWidget* configurationWidget();
virtual AccountConfigWidget* configurationWidget();
virtual QWidget* aboutWidget();
virtual void saveConfig();
virtual Attica::Content atticaContent() const;

View File

@ -36,7 +36,7 @@ bool InfoSorter( const SpotifyPlaylistInfo* left, const SpotifyPlaylistInfo* rig
}
SpotifyAccountConfig::SpotifyAccountConfig( SpotifyAccount *account )
: QWidget( 0 )
: AccountConfigWidget( 0 )
, m_ui( new Ui::SpotifyConfig )
, m_loggedInUser( 0 )
, m_account( account )

View File

@ -19,6 +19,8 @@
#ifndef SPOTIFYACCOUNTCONFIG_H
#define SPOTIFYACCOUNTCONFIG_H
#include "accounts/AccountConfigWidget.h"
#include <QWidget>
#include <QVariantMap>
#include <QTimer>
@ -40,7 +42,7 @@ namespace Accounts
class SpotifyAccount;
struct SpotifyPlaylistInfo;
class SpotifyAccountConfig : public QWidget
class SpotifyAccountConfig : public AccountConfigWidget
{
Q_OBJECT
public:

View File

@ -25,6 +25,8 @@
#include "Pipeline.h"
#include "SourceList.h"
#include "accounts/AccountConfigWidget.h"
#include "network/Servent.h"
#include "jobview/JobStatusView.h"
@ -527,13 +529,13 @@ QtScriptResolver::loadUi()
if( m.contains( "images" ) )
uiData = fixDataImagePaths( uiData, compressed, images );
m_configWidget = QPointer< QWidget >( widgetFromData( uiData, 0 ) );
m_configWidget = QPointer< AccountConfigWidget >( widgetFromData( uiData, 0 ) );
emit changed();
}
QWidget*
AccountConfigWidget*
QtScriptResolver::configUI() const
{
if( m_configWidget.isNull() )

View File

@ -134,7 +134,7 @@ public:
virtual unsigned int weight() const { return m_weight; }
virtual unsigned int timeout() const { return m_timeout; }
virtual QWidget* configUI() const;
virtual AccountConfigWidget* configUI() const;
virtual void saveConfig();
virtual ExternalResolver::ErrorState error() const;
@ -176,7 +176,7 @@ private:
ExternalResolver::ErrorState m_error;
QtScriptResolverHelper* m_resolverHelper;
QPointer< QWidget > m_configWidget;
QPointer< AccountConfigWidget > m_configWidget;
QList< QVariant > m_dataWidgets;
};

View File

@ -28,6 +28,7 @@
#include "Pipeline.h"
#include "SourceList.h"
#include "accounts/AccountConfigWidget.h"
#include "utils/TomahawkUtilsGui.h"
#include "utils/Logger.h"
@ -427,7 +428,7 @@ ScriptResolver::setupConfWidget( const QVariantMap& m )
if ( m.contains( "images" ) )
uiData = fixDataImagePaths( uiData, compressed, m[ "images" ].toMap() );
m_configWidget = QPointer< QWidget >( widgetFromData( uiData, 0 ) );
m_configWidget = QPointer< AccountConfigWidget >( widgetFromData( uiData, 0 ) );
emit changed();
}
@ -514,7 +515,7 @@ ScriptResolver::setIcon( const QPixmap& icon )
}
QWidget*
AccountConfigWidget*
ScriptResolver::configUI() const
{
if ( m_configWidget.isNull() )

View File

@ -49,7 +49,7 @@ public:
virtual void setIcon( const QPixmap& icon );
virtual QWidget* configUI() const;
virtual AccountConfigWidget* configUI() const;
virtual void saveConfig();
virtual ExternalResolver::ErrorState error() const;
@ -87,7 +87,7 @@ private:
QString m_name;
QPixmap m_icon;
unsigned int m_weight, m_preference, m_timeout, m_num_restarts;
QPointer< QWidget > m_configWidget;
QPointer< AccountConfigWidget > m_configWidget;
quint32 m_msgsize;
QByteArray m_msg;

View File

@ -23,6 +23,7 @@
#include "accounts/Account.h"
#include "accounts/AccountManager.h"
#include "accounts/DelegateConfigWrapper.h"
#include "accounts/AccountConfigWidget.h"
#include "TomahawkSettings.h"
namespace TomahawkUtils