1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-04 13:17:34 +02:00

Pass account to DelegateConfigWrapper

This commit is contained in:
Dominik Schmidt
2014-12-10 19:38:34 +01:00
parent fbc547f882
commit 1c0deb7115
3 changed files with 20 additions and 11 deletions

View File

@@ -16,18 +16,24 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "DelegateConfigWrapper.h" #include "DelegateConfigWrapper.h"
#include "Account.h"
#include "AccountConfigWidget.h" #include "AccountConfigWidget.h"
#include <QMessageBox> #include <QMessageBox>
DelegateConfigWrapper::DelegateConfigWrapper( AccountConfigWidget* conf, QWidget* aboutWidget, const QString& title, QWidget* parent, Qt::WindowFlags flags ) DelegateConfigWrapper::DelegateConfigWrapper( Tomahawk::Accounts::Account* account, QWidget* parent, Qt::WindowFlags flags )
: QDialog( parent, flags ) : QDialog( parent, flags )
, m_widget( conf ) , m_account( account )
, m_aboutW( aboutWidget ) , m_widget( account->configurationWidget() )
, m_aboutW( account->aboutWidget() )
, m_buttons( nullptr )
, m_okButton( nullptr )
, m_deleteButton( nullptr )
, m_deleted( false ) , m_deleted( false )
{ {
setWindowTitle( title ); setWindowTitle( tr("%1 Config" ).arg( account->accountFriendlyName() ) );
QVBoxLayout* v = new QVBoxLayout( this ); QVBoxLayout* v = new QVBoxLayout( this );
v->setContentsMargins( 0, 0, 0, 0 ); v->setContentsMargins( 0, 0, 0, 0 );
v->addWidget( m_widget ); v->addWidget( m_widget );
@@ -66,8 +72,8 @@ DelegateConfigWrapper::DelegateConfigWrapper( AccountConfigWidget* conf, QWidget
setSizeGripEnabled( false ); setSizeGripEnabled( false );
updateSizeHint(); updateSizeHint();
if ( conf->metaObject()->indexOfSignal( "sizeHintChanged()" ) > -1 ) if ( m_widget->metaObject()->indexOfSignal( "sizeHintChanged()" ) > -1 )
connect( conf, SIGNAL( sizeHintChanged() ), this, SLOT( updateSizeHint() ) ); connect( m_widget, SIGNAL( sizeHintChanged() ), this, SLOT( updateSizeHint() ) );
} }

View File

@@ -18,6 +18,8 @@
#ifndef RESOLVER_CONFIG_WRAPPER #ifndef RESOLVER_CONFIG_WRAPPER
#define RESOLVER_CONFIG_WRAPPER #define RESOLVER_CONFIG_WRAPPER
#include "Account.h"
#include <QDialog> #include <QDialog>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QVBoxLayout> #include <QVBoxLayout>
@@ -30,7 +32,7 @@ class DelegateConfigWrapper : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
DelegateConfigWrapper( AccountConfigWidget* conf, QWidget* aboutWidget, const QString& title, QWidget* parent, Qt::WindowFlags flags = 0 ); DelegateConfigWrapper( Tomahawk::Accounts::Account* account, QWidget* parent, Qt::WindowFlags flags = 0 );
~DelegateConfigWrapper() {} ~DelegateConfigWrapper() {}
@@ -54,9 +56,10 @@ private slots:
void aboutClicked( bool ); void aboutClicked( bool );
private: private:
QDialogButtonBox* m_buttons; Tomahawk::Accounts::Account* m_account;
AccountConfigWidget* m_widget; AccountConfigWidget* m_widget;
QWidget* m_aboutW; QWidget* m_aboutW;
QDialogButtonBox* m_buttons;
QPushButton *m_okButton, *m_deleteButton; QPushButton *m_okButton, *m_deleteButton;
bool m_deleted; bool m_deleted;
}; };

View File

@@ -100,7 +100,7 @@ createAccountFromFactory( Tomahawk::Accounts::AccountFactory* factory, QWidget*
{ {
/*#ifdef Q_OS_MAC /*#ifdef Q_OS_MAC
// on osx a sheet needs to be non-modal // on osx a sheet needs to be non-modal
DelegateConfigWrapper* dialog = new DelegateConfigWrapper( account->configurationWidget(), account->aboutWidget(), QObject::tr( "%1 Config" ).arg( account->accountFriendlyName() ), parent, Qt::Sheet ); DelegateConfigWrapper* dialog = new DelegateConfigWrapper( account, parent, Qt::Sheet );
dialog->setProperty( "accountplugin", QVariant::fromValue< QObject* >( account ) ); dialog->setProperty( "accountplugin", QVariant::fromValue< QObject* >( account ) );
UtilsObject* obj = new UtilsObject( dialog ); UtilsObject* obj = new UtilsObject( dialog );
@@ -111,7 +111,7 @@ createAccountFromFactory( Tomahawk::Accounts::AccountFactory* factory, QWidget*
dialog->show(); dialog->show();
#else*/ #else*/
DelegateConfigWrapper dialog( account->configurationWidget(), account->aboutWidget(), QObject::tr( "%1 Config" ).arg( account->accountFriendlyName() ), parent ); DelegateConfigWrapper dialog( account, parent );
QPointer< DelegateConfigWrapper > watcher( &dialog ); QPointer< DelegateConfigWrapper > watcher( &dialog );
if( account->configurationWidget()->metaObject()->indexOfSignal( "dataError(bool)" ) > -1 ) if( account->configurationWidget()->metaObject()->indexOfSignal( "dataError(bool)" ) > -1 )
@@ -140,7 +140,7 @@ openAccountConfig( Tomahawk::Accounts::Account* account, QWidget* parent, bool s
if( account->configurationWidget() ) if( account->configurationWidget() )
{ {
//#ifndef Q_OS_MAC //#ifndef Q_OS_MAC
DelegateConfigWrapper dialog( account->configurationWidget(), account->aboutWidget(), QObject::tr("%1 Config" ).arg( account->accountFriendlyName() ), parent ); DelegateConfigWrapper dialog( account, parent );
dialog.setShowDelete( showDelete ); dialog.setShowDelete( showDelete );
QPointer< DelegateConfigWrapper > watcher( &dialog ); QPointer< DelegateConfigWrapper > watcher( &dialog );
int ret = dialog.exec(); int ret = dialog.exec();