1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-17 14:28:24 +01:00

Add ScriptAccount debugger menu to SettingsDialog/AccountListWidget

This commit is contained in:
Dominik Schmidt 2016-02-16 01:57:03 +01:00
parent f13ea2f6df
commit 3c00f36df6
4 changed files with 54 additions and 1 deletions

View File

@ -517,7 +517,8 @@ ResolverAccount::removeBundle()
}
void ResolverAccount::testConfig()
void
ResolverAccount::testConfig()
{
// HACK: move to JSAccount once we have that properly
JSResolver* resolver = qobject_cast< Tomahawk::JSResolver* >( m_resolver );
@ -535,6 +536,13 @@ void ResolverAccount::testConfig()
}
ExternalResolverGui*
ResolverAccount::resolver() const
{
return m_resolver;
}
void
ResolverAccount::onTestConfig( const QVariantMap& result )
{

View File

@ -101,6 +101,8 @@ public:
void testConfig() override;
ExternalResolverGui* resolver() const;
private slots:
void resolverChanged();
void onTestConfig( const QVariantMap& result );

View File

@ -59,6 +59,8 @@
#include "jobview/ErrorStatusMessage.h"
#include "utils/NetworkAccessManager.h"
#include "utils/NetworkProxyFactory.h"
#include "resolvers/JSAccount.h"
#include "resolvers/JSResolver.h"
#include <QDesktopServices>
#include <QFileDialog>
@ -68,6 +70,7 @@
#include <QVBoxLayout>
#include <QSizeGrip>
#include <QToolBar>
#include <QMenu>
using namespace Tomahawk;
using namespace Accounts;
@ -87,6 +90,7 @@ SettingsDialog::SettingsDialog(QObject *parent )
, m_restartRequired( false )
, m_accountModel( 0 )
, m_sipSpinner( 0 )
, m_contextMenu( 0 )
{
m_accountsWidget->setFont( TomahawkUtils::systemFont() );
m_collectionWidget->setFont( TomahawkUtils::systemFont() );
@ -144,6 +148,12 @@ SettingsDialog::SettingsDialog(QObject *parent )
m_accountsWidgetUi->accountsView->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
m_accountsWidgetUi->accountsView->setMouseTracking( true );
m_contextMenu = new QMenu( m_accountsWidgetUi->accountsView );
m_contextMenu->setFont( TomahawkUtils::systemFont() );
connect( m_accountsWidgetUi->accountsView, SIGNAL( customContextMenuRequested( QPoint ) ), SLOT( onCustomContextMenu( QPoint ) ) );
QAction* showDebuggerAction = m_contextMenu->addAction( tr( "Open Account &Debugger..." ) );
connect( showDebuggerAction, SIGNAL( triggered(bool) ), SLOT( onShowDebuggerForSelectedAccount() ) );
connect( accountDelegate, SIGNAL( openConfig( Tomahawk::Accounts::Account* ) ), SLOT( openAccountConfig( Tomahawk::Accounts::Account* ) ) );
connect( accountDelegate, SIGNAL( openConfig( Tomahawk::Accounts::AccountFactory* ) ), SLOT( openAccountFactoryConfig( Tomahawk::Accounts::AccountFactory* ) ) );
connect( accountDelegate, SIGNAL( update( QModelIndex ) ), m_accountsWidgetUi->accountsView, SLOT( update( QModelIndex ) ) );
@ -380,6 +390,34 @@ SettingsDialog::onRejected()
}
void
SettingsDialog::onCustomContextMenu( const QPoint& point )
{
QModelIndex index = m_accountsWidgetUi->accountsView->indexAt( point );
if ( !index.isValid() )
return;
// HACK until there is a proper ScriptAccount
ResolverAccount* account = qobject_cast< ResolverAccount* >( m_accountProxy->data( index, AccountModel::AccountData ).value< Tomahawk::Accounts::Account* >() );
if ( !account )
return;
Tomahawk::JSResolver* jsResolver = qobject_cast< Tomahawk::JSResolver* >( account->resolver() );
if ( !jsResolver )
return;
m_contextMenu->exec( m_accountsWidgetUi->accountsView->mapToGlobal( point ) );
}
void
SettingsDialog::onShowDebuggerForSelectedAccount()
{
ResolverAccount* account = m_accountProxy->data( m_accountsWidgetUi->accountsView->currentIndex(), AccountModel::AccountData ).value< ResolverAccount* >();
Tomahawk::JSResolver* jsResolver = qobject_cast< Tomahawk::JSResolver* >( account->resolver() );
jsResolver->scriptAccount()->showDebugger();
}
void
SettingsDialog::changeEvent( QEvent *e )
{

View File

@ -37,6 +37,7 @@ class SipPlugin;
class ResolversModel;
class QNetworkReply;
class QToolbarTabDialog;
class QMenu;
namespace Ui
{
@ -130,6 +131,9 @@ private slots:
void saveSettings();
void onRejected();
void onCustomContextMenu( const QPoint& point );
void onShowDebuggerForSelectedAccount();
private:
Ui_Settings_Accounts* m_accountsWidgetUi;
QWidget* m_accountsWidget;
@ -152,6 +156,7 @@ private:
Tomahawk::Accounts::AccountModelFilterProxy* m_accountProxy;
QHash<QString, QString> m_downloadsFormats;
AnimatedSpinner* m_sipSpinner;
QMenu* m_contextMenu;
};
#endif // SETTINGSDIALOG_H