mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-22 21:54:00 +02:00
Add WIP test login button for spotify
This commit is contained in:
@@ -127,7 +127,7 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
|
|||||||
if ( m_qidToSlotMap.contains( qid ) )
|
if ( m_qidToSlotMap.contains( qid ) )
|
||||||
{
|
{
|
||||||
QObject* receiver = m_qidToSlotMap[ qid ].first;
|
QObject* receiver = m_qidToSlotMap[ qid ].first;
|
||||||
const QString& slot = m_qidToSlotMap[ qid ].second;
|
QString slot = m_qidToSlotMap[ qid ].second;
|
||||||
m_qidToSlotMap.remove( qid );
|
m_qidToSlotMap.remove( qid );
|
||||||
|
|
||||||
QMetaObject::invokeMethod( receiver, slot.toLatin1(), Q_ARG( QString, msgType ), Q_ARG( QVariantMap, msg ) );
|
QMetaObject::invokeMethod( receiver, slot.toLatin1(), Q_ARG( QString, msgType ), Q_ARG( QVariantMap, msg ) );
|
||||||
|
@@ -34,6 +34,15 @@ SpotifyAccountConfig::SpotifyAccountConfig( SpotifyAccount *account )
|
|||||||
{
|
{
|
||||||
m_ui->setupUi( this );
|
m_ui->setupUi( this );
|
||||||
|
|
||||||
|
connect( m_ui->verifyCreds, SIGNAL( clicked( bool ) ), this, SLOT( verifyLogin() ) );
|
||||||
|
|
||||||
|
m_resetTimer.setSingleShot( true );
|
||||||
|
m_resetTimer.setInterval( 10000 );
|
||||||
|
|
||||||
|
connect( &m_resetTimer, SIGNAL( timeout() ), this, SLOT( resetVerifyButton() ) );
|
||||||
|
connect( m_ui->usernameEdit, SIGNAL( textChanged( QString ) ), this, SLOT( clearVerifyButton() ) );
|
||||||
|
connect( m_ui->passwordEdit, SIGNAL( textChanged( QString ) ), this, SLOT( clearVerifyButton() ) );
|
||||||
|
|
||||||
loadFromConfig();
|
loadFromConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,3 +103,48 @@ SpotifyAccountConfig::setPlaylists( const QList<SpotifyPlaylistInfo *>& playlist
|
|||||||
item->setCheckState( pl->sync ? Qt::Checked : Qt::Unchecked );
|
item->setCheckState( pl->sync ? Qt::Checked : Qt::Unchecked );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SpotifyAccountConfig::verifyLogin()
|
||||||
|
{
|
||||||
|
QVariantMap msg;
|
||||||
|
msg[ "_msgtype" ] = "checkLogin";
|
||||||
|
msg[ "username" ] = username();
|
||||||
|
msg[ "password" ] = password();
|
||||||
|
|
||||||
|
m_account->sendMessage( msg, this, "verifyResult" );
|
||||||
|
|
||||||
|
m_ui->verifyCreds->setText( tr( "Verifying..." ) );
|
||||||
|
m_ui->verifyCreds->setEnabled( false );
|
||||||
|
|
||||||
|
m_resetTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SpotifyAccountConfig::resetVerifyButton()
|
||||||
|
{
|
||||||
|
m_ui->verifyCreds->setText( tr( "Verify" ) );
|
||||||
|
m_ui->verifyCreds->setEnabled( true );
|
||||||
|
m_ui->verifyCreds->setToolTip( QString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SpotifyAccountConfig::verifyResult( const QString& msgType, const QVariantMap& msg )
|
||||||
|
{
|
||||||
|
const bool success = msg.value( "success" ).toBool();
|
||||||
|
const QString message = msg.value( "message" ).toString();
|
||||||
|
|
||||||
|
m_resetTimer.stop();
|
||||||
|
|
||||||
|
if ( success )
|
||||||
|
m_ui->verifyCreds->setText( tr( "Success!" ) );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ui->verifyCreds->setText( tr( "Failed!" ) );
|
||||||
|
m_ui->verifyCreds->setEnabled( true );
|
||||||
|
m_ui->verifyCreds->setToolTip( message );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -20,6 +20,8 @@
|
|||||||
#define SPOTIFYACCOUNTCONFIG_H
|
#define SPOTIFYACCOUNTCONFIG_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QVariantMap>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@@ -49,10 +51,17 @@ public:
|
|||||||
void loadFromConfig();
|
void loadFromConfig();
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void verifyResult( const QString& msgType, const QVariantMap& msg );
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void verifyLogin();
|
||||||
|
void resetVerifyButton();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SpotifyConfig* m_ui;
|
Ui::SpotifyConfig* m_ui;
|
||||||
SpotifyAccount* m_account;
|
SpotifyAccount* m_account;
|
||||||
|
QTimer m_resetTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>403</width>
|
<width>403</width>
|
||||||
<height>437</height>
|
<height>439</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -20,9 +20,6 @@
|
|||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="margin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
@@ -70,38 +67,52 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item row="0" column="0">
|
<item>
|
||||||
<widget class="QLabel" name="usernameLabel">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
<property name="text">
|
<property name="fieldGrowthPolicy">
|
||||||
<string>Username:</string>
|
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="usernameLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Username:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="usernameEdit">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Username or Facebook Email</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="passwordLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Password:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="passwordEdit">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="echoMode">
|
||||||
|
<enum>QLineEdit::Password</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item>
|
||||||
<widget class="QLineEdit" name="usernameEdit">
|
<widget class="QPushButton" name="verifyCreds">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string>Verify</string>
|
||||||
</property>
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>Username or Facebook Email</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="passwordLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Password:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLineEdit" name="passwordEdit">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="echoMode">
|
|
||||||
<enum>QLineEdit::Password</enum>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Reference in New Issue
Block a user