1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-22 21:54:00 +02:00

Lock external account config UI, launch KDE Telepathy config dialog.

This commit is contained in:
Teo Mrnjavac
2013-06-19 16:45:34 +02:00
parent bec87f692d
commit e80a5ba2e5
9 changed files with 211 additions and 7 deletions

View File

@@ -23,7 +23,9 @@
#include "accounts/AccountManager.h" #include "accounts/AccountManager.h"
#include "accounts/ConfigStorage.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/TomahawkUtilsGui.h"
#include <QMessageBox> #include <QMessageBox>
@@ -48,9 +50,41 @@ XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent )
m_ui->xmppPublishTracksCheckbox->setChecked( account->configuration().contains( "publishtracks" ) ? account->configuration()[ "publishtracks" ].toBool() : true); m_ui->xmppPublishTracksCheckbox->setChecked( account->configuration().contains( "publishtracks" ) ? account->configuration()[ "publishtracks" ].toBool() : true);
m_ui->xmppEnforceSecureCheckbox->setChecked( account->configuration().contains( "enforcesecure" ) ? account->configuration()[ "enforcesecure" ].toBool() : false); m_ui->xmppEnforceSecureCheckbox->setChecked( account->configuration().contains( "enforcesecure" ) ? account->configuration()[ "enforcesecure" ].toBool() : false);
m_ui->jidExistsLabel->hide(); m_ui->jidExistsLabel->hide();
m_ui->xmppConfigFrame->hide();
connect( m_ui->xmppUsername, SIGNAL( textChanged( QString ) ), SLOT( onCheckJidExists( QString ) ) ); connect( m_ui->xmppUsername, SIGNAL( textChanged( QString ) ), SLOT( onCheckJidExists( QString ) ) );
if ( m_account->configuration()[ "read-only" ].toBool() )
{
m_ui->xmppUsername->setEnabled( false );
m_ui->xmppPassword->setEnabled( false );
m_ui->xmppServer->setEnabled( false );
m_ui->xmppPort->setEnabled( false );
m_ui->xmppEnforceSecureCheckbox->setEnabled( false );
m_ui->xmppPublishTracksCheckbox->setEnabled( false );
}
ConfigStorage* cs = AccountManager::instance()->configStorageForAccount( m_account->accountId() );
if ( cs->id() != "localconfigstorage" )
{
m_ui->xmppBlurb->hide();
m_ui->xmppConfigFrame->show();
m_ui->xmppConfigLabel->setText( tr( "Account provided by %1." )
.arg( cs->prettyName() ) );
m_ui->xmppConfigIcon->setPixmap( cs->icon().scaled( TomahawkUtils::defaultIconSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
m_ui->xmppConfigLaunchDialog->setIcon( TomahawkUtils::defaultPixmap( TomahawkUtils::Configure ) );
connect( m_ui->xmppConfigLaunchDialog, SIGNAL( clicked() ),
this, SLOT( launchExternalConfigDialog() ) );
}
}
void
XmppConfigWidget::launchExternalConfigDialog()
{
ConfigStorage* cs = AccountManager::instance()->configStorageForAccount( m_account->accountId() );
cs->execConfigDialog();
} }

View File

@@ -56,6 +56,7 @@ signals:
private slots: private slots:
void onCheckJidExists( const QString& jid ); void onCheckJidExists( const QString& jid );
void launchExternalConfigDialog();
private: private:
Ui::XmppConfigWidget *m_ui; Ui::XmppConfigWidget *m_ui;

View File

@@ -1,15 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>XmppConfigWidget</class> <class>XmppConfigWidget</class>
<widget class="QWidget" name="XmppConfig"> <widget class="QWidget" name="XmppConfigWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>451</width> <width>451</width>
<height>335</height> <height>337</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>451</width>
<height>0</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Xmpp Configuration</string> <string>Xmpp Configuration</string>
</property> </property>
@@ -35,7 +41,7 @@
<string/> <string/>
</property> </property>
<property name="pixmap"> <property name="pixmap">
<pixmap resource="resources.qrc">:/xmpp-account/xmpp-icon.png</pixmap> <pixmap resource="resources.qrc">:/xmpp-account/xmpp-icon.png</pixmap>
</property> </property>
</widget> </widget>
</item> </item>
@@ -69,15 +75,18 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<spacer name="horizontalSpacer_3"> <spacer name="horizontalSpacer_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>0</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
@@ -85,9 +94,18 @@
</item> </item>
<item> <item>
<widget class="QLabel" name="xmppBlurb"> <widget class="QLabel" name="xmppBlurb">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Enter your Xmpp login to connect with your friends using Tomahawk!</string> <string>Enter your Xmpp login to connect with your friends using Tomahawk!</string>
</property> </property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@@ -95,9 +113,12 @@
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>0</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
@@ -105,6 +126,85 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QFrame" name="xmppConfigFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="spacing">
<number>5</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="xmppConfigIcon">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="xmppConfigLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="xmppConfigLaunchDialog">
<property name="toolTip">
<string>Configure</string>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">

View File

@@ -37,5 +37,26 @@ ConfigStorage::~ConfigStorage()
} }
QString
ConfigStorage::prettyName() const
{
return QString();
}
QPixmap
ConfigStorage::icon() const
{
return QPixmap();
}
bool
ConfigStorage::execConfigDialog()
{
return false;
}
} //ns } //ns
} //ns } //ns

View File

@@ -41,6 +41,11 @@ public:
virtual void init() = 0; virtual void init() = 0;
virtual QString id() const = 0; virtual QString id() const = 0;
virtual QString prettyName() const;
virtual QPixmap icon() const;
virtual bool execConfigDialog();
virtual QStringList accountIds() const = 0; virtual QStringList accountIds() const = 0;

View File

@@ -28,6 +28,7 @@
#include <TelepathyQt/PendingOperation> #include <TelepathyQt/PendingOperation>
#include <TelepathyQt/AccountSet> #include <TelepathyQt/AccountSet>
#include <QProcess>
#include <QTimer> #include <QTimer>
@@ -60,6 +61,37 @@ Tomahawk::Accounts::TelepathyConfigStorage::id() const
} }
QString
Tomahawk::Accounts::TelepathyConfigStorage::prettyName() const
{
return tr( "the KDE instant messaging framework" );
}
QPixmap
Tomahawk::Accounts::TelepathyConfigStorage::icon() const
{
return QPixmap( ":/telepathy/kde.png" );
}
bool
Tomahawk::Accounts::TelepathyConfigStorage::execConfigDialog()
{
QProcess kcm;
kcm.start( "kcmshell4 kcm_ktp_accounts" );
if ( !kcm.waitForStarted() )
return false;
if ( !kcm.waitForFinished( 600000 ) )
return false;
//TODO: this should probably be async
return true;
}
void void
Tomahawk::Accounts::TelepathyConfigStorage::onTpAccountManagerReady( Tp::PendingOperation* op ) Tomahawk::Accounts::TelepathyConfigStorage::onTpAccountManagerReady( Tp::PendingOperation* op )
{ {
@@ -172,7 +204,7 @@ Tomahawk::Accounts::TelepathyConfigStorage::load( const QString& accountId, Acco
Tp::AccountPtr account = m_tpam->accountForObjectPath( accountIdToTelepathyPath( accountId ) ); Tp::AccountPtr account = m_tpam->accountForObjectPath( accountIdToTelepathyPath( accountId ) );
cfg.accountFriendlyName = account->normalizedName(); cfg.accountFriendlyName = "Tp:" + account->normalizedName();
cfg.enabled = true; cfg.enabled = true;
cfg.acl = QVariantMap(); cfg.acl = QVariantMap();
@@ -206,6 +238,8 @@ Tomahawk::Accounts::TelepathyConfigStorage::load( const QString& accountId, Acco
QVariant credentials = c->credentials( m_credentialsServiceName, account->uniqueIdentifier() ); QVariant credentials = c->credentials( m_credentialsServiceName, account->uniqueIdentifier() );
if ( credentials.type() == QVariant::String ) if ( credentials.type() == QVariant::String )
cfg.credentials[ "password" ] = credentials.toString(); cfg.credentials[ "password" ] = credentials.toString();
cfg.configuration[ "read-only" ] = true;
} }

View File

@@ -45,6 +45,10 @@ public:
void init(); void init();
QString id() const; QString id() const;
QString prettyName() const;
QPixmap icon() const;
bool execConfigDialog();
QStringList accountIds() const; QStringList accountIds() const;

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/telepathy">
<file>kde.png</file>
</qresource>
</RCC>