mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-13 20:39:57 +01:00
Add WIP test login button for spotify
This commit is contained in:
parent
c0ab42021e
commit
d6c7e7f57b
@ -127,7 +127,7 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
|
||||
if ( m_qidToSlotMap.contains( qid ) )
|
||||
{
|
||||
QObject* receiver = m_qidToSlotMap[ qid ].first;
|
||||
const QString& slot = m_qidToSlotMap[ qid ].second;
|
||||
QString slot = m_qidToSlotMap[ qid ].second;
|
||||
m_qidToSlotMap.remove( qid );
|
||||
|
||||
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 );
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@ -94,3 +103,48 @@ SpotifyAccountConfig::setPlaylists( const QList<SpotifyPlaylistInfo *>& playlist
|
||||
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
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVariantMap>
|
||||
#include <QTimer>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@ -49,10 +51,17 @@ public:
|
||||
void loadFromConfig();
|
||||
void saveSettings();
|
||||
|
||||
public slots:
|
||||
void verifyResult( const QString& msgType, const QVariantMap& msg );
|
||||
|
||||
private slots:
|
||||
void verifyLogin();
|
||||
void resetVerifyButton();
|
||||
|
||||
private:
|
||||
Ui::SpotifyConfig* m_ui;
|
||||
SpotifyAccount* m_account;
|
||||
|
||||
QTimer m_resetTimer;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>403</width>
|
||||
<height>437</height>
|
||||
<height>439</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -20,9 +20,6 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
@ -70,38 +67,52 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="usernameLabel">
|
||||
<property name="text">
|
||||
<string>Username:</string>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</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 row="0" column="1">
|
||||
<widget class="QLineEdit" name="usernameEdit">
|
||||
<item>
|
||||
<widget class="QPushButton" name="verifyCreds">
|
||||
<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>
|
||||
<string>Verify</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user