mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 20:00:13 +02:00
Add ScriptAccount debugger menu to SettingsDialog/AccountListWidget
This commit is contained in:
@@ -517,7 +517,8 @@ ResolverAccount::removeBundle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ResolverAccount::testConfig()
|
void
|
||||||
|
ResolverAccount::testConfig()
|
||||||
{
|
{
|
||||||
// HACK: move to JSAccount once we have that properly
|
// HACK: move to JSAccount once we have that properly
|
||||||
JSResolver* resolver = qobject_cast< Tomahawk::JSResolver* >( m_resolver );
|
JSResolver* resolver = qobject_cast< Tomahawk::JSResolver* >( m_resolver );
|
||||||
@@ -535,6 +536,13 @@ void ResolverAccount::testConfig()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExternalResolverGui*
|
||||||
|
ResolverAccount::resolver() const
|
||||||
|
{
|
||||||
|
return m_resolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ResolverAccount::onTestConfig( const QVariantMap& result )
|
ResolverAccount::onTestConfig( const QVariantMap& result )
|
||||||
{
|
{
|
||||||
|
@@ -101,6 +101,8 @@ public:
|
|||||||
|
|
||||||
void testConfig() override;
|
void testConfig() override;
|
||||||
|
|
||||||
|
ExternalResolverGui* resolver() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void resolverChanged();
|
void resolverChanged();
|
||||||
void onTestConfig( const QVariantMap& result );
|
void onTestConfig( const QVariantMap& result );
|
||||||
|
@@ -59,6 +59,8 @@
|
|||||||
#include "jobview/ErrorStatusMessage.h"
|
#include "jobview/ErrorStatusMessage.h"
|
||||||
#include "utils/NetworkAccessManager.h"
|
#include "utils/NetworkAccessManager.h"
|
||||||
#include "utils/NetworkProxyFactory.h"
|
#include "utils/NetworkProxyFactory.h"
|
||||||
|
#include "resolvers/JSAccount.h"
|
||||||
|
#include "resolvers/JSResolver.h"
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
@@ -68,6 +70,7 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QSizeGrip>
|
#include <QSizeGrip>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
using namespace Accounts;
|
using namespace Accounts;
|
||||||
@@ -87,6 +90,7 @@ SettingsDialog::SettingsDialog(QObject *parent )
|
|||||||
, m_restartRequired( false )
|
, m_restartRequired( false )
|
||||||
, m_accountModel( 0 )
|
, m_accountModel( 0 )
|
||||||
, m_sipSpinner( 0 )
|
, m_sipSpinner( 0 )
|
||||||
|
, m_contextMenu( 0 )
|
||||||
{
|
{
|
||||||
m_accountsWidget->setFont( TomahawkUtils::systemFont() );
|
m_accountsWidget->setFont( TomahawkUtils::systemFont() );
|
||||||
m_collectionWidget->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->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
|
||||||
m_accountsWidgetUi->accountsView->setMouseTracking( true );
|
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::Account* ) ), SLOT( openAccountConfig( Tomahawk::Accounts::Account* ) ) );
|
||||||
connect( accountDelegate, SIGNAL( openConfig( Tomahawk::Accounts::AccountFactory* ) ), SLOT( openAccountFactoryConfig( Tomahawk::Accounts::AccountFactory* ) ) );
|
connect( accountDelegate, SIGNAL( openConfig( Tomahawk::Accounts::AccountFactory* ) ), SLOT( openAccountFactoryConfig( Tomahawk::Accounts::AccountFactory* ) ) );
|
||||||
connect( accountDelegate, SIGNAL( update( QModelIndex ) ), m_accountsWidgetUi->accountsView, SLOT( update( QModelIndex ) ) );
|
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
|
void
|
||||||
SettingsDialog::changeEvent( QEvent *e )
|
SettingsDialog::changeEvent( QEvent *e )
|
||||||
{
|
{
|
||||||
|
@@ -37,6 +37,7 @@ class SipPlugin;
|
|||||||
class ResolversModel;
|
class ResolversModel;
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
class QToolbarTabDialog;
|
class QToolbarTabDialog;
|
||||||
|
class QMenu;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@@ -130,6 +131,9 @@ private slots:
|
|||||||
void saveSettings();
|
void saveSettings();
|
||||||
void onRejected();
|
void onRejected();
|
||||||
|
|
||||||
|
void onCustomContextMenu( const QPoint& point );
|
||||||
|
void onShowDebuggerForSelectedAccount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_Settings_Accounts* m_accountsWidgetUi;
|
Ui_Settings_Accounts* m_accountsWidgetUi;
|
||||||
QWidget* m_accountsWidget;
|
QWidget* m_accountsWidget;
|
||||||
@@ -152,6 +156,7 @@ private:
|
|||||||
Tomahawk::Accounts::AccountModelFilterProxy* m_accountProxy;
|
Tomahawk::Accounts::AccountModelFilterProxy* m_accountProxy;
|
||||||
QHash<QString, QString> m_downloadsFormats;
|
QHash<QString, QString> m_downloadsFormats;
|
||||||
AnimatedSpinner* m_sipSpinner;
|
AnimatedSpinner* m_sipSpinner;
|
||||||
|
QMenu* m_contextMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGSDIALOG_H
|
#endif // SETTINGSDIALOG_H
|
||||||
|
Reference in New Issue
Block a user