1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-06 12:10:47 +02:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Dominik Schmidt
21897ef024 Try to make xmppconfigdialog more friendly to user joe 2013-01-24 00:21:06 +01:00
Dominik Schmidt
643dda78dc Check for a valid xmpp id in the config widget 2013-01-23 20:57:58 +01:00
Dominik Schmidt
4ebec06484 Refuse to close config dialogs with OK if settings are invalid 2013-01-23 20:44:06 +01:00
Dominik Schmidt
dd313488b8 Introduce AccountConfigWidget type for handling errors later on 2013-01-23 19:35:48 +01:00
31 changed files with 530 additions and 303 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

@@ -33,10 +33,11 @@ namespace Tomahawk
namespace Accounts
{
XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent ) :
QWidget( parent ),
m_ui( new Ui::XmppConfigWidget ),
m_account( account )
XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent )
: AccountConfigWidget( parent )
, m_ui( new Ui::XmppConfigWidget )
, m_account( account )
, m_disableChecksForGoogle( false )
{
m_ui->setupUi( this );
@@ -48,6 +49,8 @@ XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent ) :
m_ui->xmppEnforceSecureCheckbox->setChecked( account->configuration().contains( "enforcesecure" ) ? account->configuration()[ "enforcesecure" ].toBool() : false);
m_ui->jidExistsLabel->hide();
m_ui->tabWidget->setCurrentIndex( 0 );
connect( m_ui->xmppUsername, SIGNAL( textChanged( QString ) ), SLOT( onCheckJidExists( QString ) ) );
}
@@ -109,6 +112,35 @@ XmppConfigWidget::onCheckJidExists( QString jid )
}
void
XmppConfigWidget::checkForErrors()
{
const QString username = m_ui->xmppUsername->text().trimmed();
const QStringList usernameParts = username.split( '@', QString::KeepEmptyParts );
QString errorMessage;
if( username.isEmpty() )
{
errorMessage.append( tr( "You forgot to enter your username!" ) );
}
//HACK: don't check for xmpp id being an "email address"
if( !m_disableChecksForGoogle )
{
if( usernameParts.count() != 2 || usernameParts.at( 0 ).isEmpty() || ( usernameParts.count() == 2 && usernameParts.at( 1 ).isEmpty() ) )
{
errorMessage.append( tr( "Your Xmpp Id should look like an email address" ) );
}
}
if( !errorMessage.isEmpty() )
{
errorMessage.append( tr( "\n\nExample:\nusername@jabber.org" ) );
m_errors.append( errorMessage );
}
}
}
}

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
@@ -49,6 +49,8 @@ public:
void saveConfig();
virtual void checkForErrors();
signals:
void dataError( bool exists );
@@ -59,6 +61,8 @@ private:
Ui::XmppConfigWidget *m_ui;
XmppAccount *m_account;
bool m_disableChecksForGoogle;
friend class GoogleWrapper; // So google wrapper can modify the labels and text
};

View File

@@ -1,18 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>XmppConfigWidget</class>
<widget class="QWidget" name="XmppConfig">
<widget class="QWidget" name="XmppConfigWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>451</width>
<height>335</height>
<width>461</width>
<height>384</height>
</rect>
</property>
<property name="windowTitle">
<string>Xmpp Configuration</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
@@ -69,263 +72,305 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="xmppBlurb">
<property name="text">
<string>Enter your Xmpp login to connect with your friends using Tomahawk!</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Login Information</string>
<widget class="QTabWidget" name="tabWidget">
<property name="tabPosition">
<enum>QTabWidget::North</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="emailLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Xmpp ID:</string>
</property>
<property name="buddy">
<cstring>xmppUsername</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="xmppUsername">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>e.g. user@example.com</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Password:</string>
</property>
<property name="buddy">
<cstring>xmppPassword</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="xmppPassword">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="inputMask">
<string/>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="jidExistsLabel">
<property name="text">
<string>An account with this name already exists!</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="general">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;b&gt;Login&lt;/b&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="xmppBlurb">
<property name="text">
<string>Enter your Xmpp login to connect with your friends using Tomahawk!</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="emailLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Xmpp ID:</string>
</property>
<property name="buddy">
<cstring>xmppUsername</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="xmppUsername">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>e.g. user@example.com</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Password:</string>
</property>
<property name="buddy">
<cstring>xmppPassword</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="xmppPassword">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="inputMask">
<string/>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="jidExistsLabel">
<property name="text">
<string>An account with this name already exists!</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</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>40</height>
</size>
</property>
</spacer>
</item>
</layout>
<zorder>verticalSpacer_2</zorder>
<zorder>jidExistsLabel</zorder>
<zorder>label_3</zorder>
</widget>
<widget class="QWidget" name="advancedPage">
<attribute name="title">
<string>Advanced</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;b&gt;Privacy&lt;/b&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="xmppPublishTracksCheckbox">
<property name="toolTip">
<string>Lots of servers don't support this (e.g. GTalk, jabber.org)</string>
</property>
<property name="text">
<string>Publish currently playing track</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="serverSettings">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Server&lt;/span&gt; (don't change if you don't have to)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="labelXmppServer">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Host:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="buddy">
<cstring>xmppServer</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="xmppServer">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelXmppPort">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="xmppPort">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>90</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>5222</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="xmppEnforceSecureCheckbox">
<property name="text">
<string>Enforce secure connection</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxXmppAdvanced">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Advanced Xmpp Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="labelXmppServer">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Server:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>xmppServer</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="xmppServer">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelXmppPort">
<property name="text">
<string>Port:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="xmppPort">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>90</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>5222</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="xmppPublishTracksCheckbox">
<property name="toolTip">
<string>Lots of servers don't support this (e.g. GTalk, jabber.org)</string>
</property>
<property name="text">
<string>Publish currently playing track</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="xmppEnforceSecureCheckbox">
<property name="text">
<string>Enforce secure connection</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>

View File

@@ -85,6 +85,7 @@ GoogleWrapper::GoogleWrapper ( const QString& pluginID )
: XmppAccount ( pluginID )
{
XmppConfigWidget* config = static_cast< XmppConfigWidget* >( m_configWidget.data() );
config->m_disableChecksForGoogle = true;
config->m_ui->headerLabel->setText( tr( "Configure this Google Account" ) );
config->m_ui->emailLabel->setText( tr( "Google Address:" ) );
config->m_ui->xmppBlurb->setText( tr( "Enter your Google login to connect with your friends using Tomahawk!" ) );
@@ -92,7 +93,13 @@ GoogleWrapper::GoogleWrapper ( const QString& pluginID )
config->m_ui->logoLabel->setPixmap( QPixmap( ":/gmail-logo.png" ) );
config->m_ui->xmppServer->setText( "talk.google.com" );
config->m_ui->xmppPort->setValue( 5222 );
config->m_ui->groupBoxXmppAdvanced->hide();
// hide server settings
QLayoutItem *child;
while ( ( child = config->m_ui->serverSettings->takeAt( 0 ) ) != 0) {
if( child->widget() )
child->widget()->hide();
}
m_onlinePixmap = QPixmap( ":/gmail-logo.png" );
m_offlinePixmap = QPixmap( ":/gmail-offline-logo.png" );

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,51 @@
/* === 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)
{
}
void
AccountConfigWidget::checkForErrors()
{
}
const QStringList
AccountConfigWidget::errors() const
{
return m_errors;
}
void
AccountConfigWidget::resetErrors()
{
m_errors.clear();
}
bool
AccountConfigWidget::settingsValid() const
{
return m_errors.empty();
}

View File

@@ -0,0 +1,42 @@
/* === 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);
virtual void checkForErrors();
virtual const QStringList errors() const;
virtual void resetErrors();
virtual bool settingsValid() const;
protected:
QStringList m_errors;
};
#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 )
@@ -101,21 +103,42 @@ DelegateConfigWrapper::closed( QAbstractButton* b )
if ( buttons->standardButton( b ) == QDialogButtonBox::Help )
return;
// let the config widget live to see another day
layout()->removeWidget( m_widget );
m_widget->setParent( 0 );
m_widget->setVisible( false );
int doneCode = 0;
if ( buttons->standardButton( b ) == QDialogButtonBox::Ok )
done( QDialog::Accepted );
{
m_widget->resetErrors();
m_widget->checkForErrors();
if( !m_widget->settingsValid() )
{
foreach( const QString& error, m_widget->errors() )
{
QMessageBox::warning( this, tr( "Config Error" ) , error );
}
return;
}
doneCode = QDialog::Accepted;
}
else if ( b == m_deleteButton )
{
m_deleted = true;
emit closedWithDelete();
reject();
return;
}
else
done( QDialog::Rejected );
{
doneCode = QDialog::Rejected;
}
// let the config widget live to see another day
layout()->removeWidget( m_widget );
m_widget->setParent( 0 );
m_widget->setVisible( false );
done( doneCode );
}

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