mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
Refactor account dialogs into utils, and port tomahawk to automoc too
This commit is contained in:
@@ -19,7 +19,8 @@
|
|||||||
#include "AccountFactoryWrapper.h"
|
#include "AccountFactoryWrapper.h"
|
||||||
|
|
||||||
#include "accounts/Account.h"
|
#include "accounts/Account.h"
|
||||||
#include <accounts/AccountManager.h>
|
#include "accounts/AccountManager.h"
|
||||||
|
#include "guihelpers.h"
|
||||||
#include "AccountFactoryWrapperDelegate.h"
|
#include "AccountFactoryWrapperDelegate.h"
|
||||||
#include "delegateconfigwrapper.h"
|
#include "delegateconfigwrapper.h"
|
||||||
#include "ui_AccountFactoryWrapper.h"
|
#include "ui_AccountFactoryWrapper.h"
|
||||||
@@ -92,40 +93,10 @@ AccountFactoryWrapper::load()
|
|||||||
void
|
void
|
||||||
AccountFactoryWrapper::openAccountConfig( Account* account )
|
AccountFactoryWrapper::openAccountConfig( Account* account )
|
||||||
{
|
{
|
||||||
if( account->configurationWidget() )
|
TomahawkUtils::openAccountConfig( account, this, false );
|
||||||
{
|
|
||||||
#ifndef Q_WS_MAC
|
|
||||||
DelegateConfigWrapper dialog( account->configurationWidget(), QString("%1 Configuration" ).arg( account->accountFriendlyName() ), this );
|
|
||||||
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
|
||||||
int ret = dialog.exec();
|
|
||||||
if( !watcher.isNull() && ret == QDialog::Accepted )
|
|
||||||
{
|
|
||||||
// send changed config to resolver
|
|
||||||
account->saveConfig();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// on osx a sheet needs to be non-modal
|
|
||||||
DelegateConfigWrapper* dialog = new DelegateConfigWrapper( account->configurationWidget(), QString("%1 Configuration" ).arg( account->accountFriendlyName() ), this, Qt::Sheet );
|
|
||||||
dialog->setProperty( "accountplugin", QVariant::fromValue< QObject* >( account ) );
|
|
||||||
connect( dialog, SIGNAL( finished( int ) ), this, SLOT( accountConfigClosed( int ) ) );
|
|
||||||
|
|
||||||
dialog->show();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AccountFactoryWrapper::accountConfigClosed( int value )
|
|
||||||
{
|
|
||||||
if( value == QDialog::Accepted )
|
|
||||||
{
|
|
||||||
DelegateConfigWrapper* dialog = qobject_cast< DelegateConfigWrapper* >( sender() );
|
|
||||||
Account* account = qobject_cast< Account* >( dialog->property( "accountplugin" ).value< QObject* >() );
|
|
||||||
account->saveConfig();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AccountFactoryWrapper::removeAccount( Tomahawk::Accounts::Account* acct )
|
AccountFactoryWrapper::removeAccount( Tomahawk::Accounts::Account* acct )
|
||||||
{
|
{
|
||||||
|
@@ -49,7 +49,6 @@ signals:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void openAccountConfig( Tomahawk::Accounts::Account* );
|
void openAccountConfig( Tomahawk::Accounts::Account* );
|
||||||
void accountConfigClosed( int value );
|
|
||||||
void removeAccount( Tomahawk::Accounts::Account* );
|
void removeAccount( Tomahawk::Accounts::Account* );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@@ -70,63 +70,21 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
|||||||
|
|
||||||
breakpad/BreakPad.cpp
|
breakpad/BreakPad.cpp
|
||||||
|
|
||||||
|
utils/guihelpers.cpp
|
||||||
|
|
||||||
tomahawktrayicon.cpp
|
tomahawktrayicon.cpp
|
||||||
audiocontrols.cpp
|
audiocontrols.cpp
|
||||||
settingsdialog.cpp
|
settingsdialog.cpp
|
||||||
diagnosticsdialog.cpp
|
diagnosticsdialog.cpp
|
||||||
AccountDelegate.cpp
|
AccountDelegate.cpp
|
||||||
settingslistdelegate.cpp
|
settingslistdelegate.cpp
|
||||||
|
delegateconfigwrapper.cpp
|
||||||
tomahawkwindow.cpp
|
tomahawkwindow.cpp
|
||||||
LoadXSPFDialog.cpp
|
LoadXSPFDialog.cpp
|
||||||
AccountFactoryWrapper.cpp
|
AccountFactoryWrapper.cpp
|
||||||
AccountFactoryWrapperDelegate.cpp
|
AccountFactoryWrapperDelegate.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SET( tomahawkHeaders ${tomahawkHeaders}
|
|
||||||
tomahawkapp.h
|
|
||||||
|
|
||||||
web/api_v1.h
|
|
||||||
|
|
||||||
musicscanner.h
|
|
||||||
scanmanager.h
|
|
||||||
ubuntuunityhack.h
|
|
||||||
shortcuthandler.h
|
|
||||||
)
|
|
||||||
|
|
||||||
IF(LIBLASTFM_FOUND)
|
|
||||||
SET(tomahawkHeaders ${tomahawkHeaders}
|
|
||||||
scrobbler.h
|
|
||||||
)
|
|
||||||
ENDIF(LIBLASTFM_FOUND)
|
|
||||||
|
|
||||||
SET( tomahawkHeadersGui ${tomahawkHeadersGui}
|
|
||||||
sourcetree/sourcesmodel.h
|
|
||||||
sourcetree/sourcesproxymodel.h
|
|
||||||
sourcetree/sourcetreeview.h
|
|
||||||
sourcetree/sourcedelegate.h
|
|
||||||
sourcetree/animationhelper.h
|
|
||||||
sourcetree/items/sourcetreeitem.h
|
|
||||||
sourcetree/items/sourceitem.h
|
|
||||||
sourcetree/items/playlistitems.h
|
|
||||||
sourcetree/items/categoryitems.h
|
|
||||||
sourcetree/items/genericpageitems.h
|
|
||||||
sourcetree/items/temporarypageitem.h
|
|
||||||
sourcetree/items/groupitem.h
|
|
||||||
sourcetree/items/historyitem.h
|
|
||||||
|
|
||||||
tomahawktrayicon.h
|
|
||||||
audiocontrols.h
|
|
||||||
settingsdialog.h
|
|
||||||
diagnosticsdialog.h
|
|
||||||
AccountDelegate.h
|
|
||||||
settingslistdelegate.h
|
|
||||||
delegateconfigwrapper.h
|
|
||||||
tomahawkwindow.h
|
|
||||||
LoadXSPFDialog.h
|
|
||||||
AccountFactoryWrapper.h
|
|
||||||
AccountFactoryWrapperDelegate.h
|
|
||||||
)
|
|
||||||
|
|
||||||
SET( tomahawkUI ${tomahawkUI}
|
SET( tomahawkUI ${tomahawkUI}
|
||||||
tomahawkwindow.ui
|
tomahawkwindow.ui
|
||||||
diagnosticsdialog.ui
|
diagnosticsdialog.ui
|
||||||
@@ -180,17 +138,11 @@ ENDIF( UNIX )
|
|||||||
IF( APPLE )
|
IF( APPLE )
|
||||||
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/thirdparty/SPMediaKeyTap )
|
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/thirdparty/SPMediaKeyTap )
|
||||||
|
|
||||||
SET( tomahawkHeaders ${tomahawkHeaders} mac/tomahawkapp_mac.h mac/macshortcuthandler.h )
|
|
||||||
SET( tomahawkSources ${tomahawkSources} mac/tomahawkapp_mac.mm mac/macshortcuthandler.cpp )
|
SET( tomahawkSources ${tomahawkSources} mac/tomahawkapp_mac.mm mac/macshortcuthandler.cpp )
|
||||||
|
|
||||||
IF(HAVE_SPARKLE)
|
|
||||||
SET( tomahawkHeaders ${tomahawkHeaders} ${SPARKLE}/Headers )
|
|
||||||
ENDIF(HAVE_SPARKLE)
|
|
||||||
ENDIF( APPLE )
|
ENDIF( APPLE )
|
||||||
|
|
||||||
IF(GLOOX_FOUND)
|
IF(GLOOX_FOUND)
|
||||||
INCLUDE_DIRECTORIES( ${GLOOX_INCLUDE_DIR} )
|
INCLUDE_DIRECTORIES( ${GLOOX_INCLUDE_DIR} )
|
||||||
SET( tomahawkHeaders ${tomahawkHeaders} xmppbot/xmppbot.h )
|
|
||||||
SET( tomahawkSources ${tomahawkSources} xmppbot/xmppbot.cpp )
|
SET( tomahawkSources ${tomahawkSources} xmppbot/xmppbot.cpp )
|
||||||
ENDIF(GLOOX_FOUND)
|
ENDIF(GLOOX_FOUND)
|
||||||
|
|
||||||
@@ -206,26 +158,26 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
|
|||||||
|
|
||||||
include( ${CMAKE_SOURCE_DIR}/lang/translations.cmake )
|
include( ${CMAKE_SOURCE_DIR}/lang/translations.cmake )
|
||||||
|
|
||||||
SET( final_src ${final_src} ${tomahawkMoc} ${tomahawkSources} ${tomahawkHeaders} ${trans_outfile})
|
SET( final_src ${final_src} ${tomahawkMoc} ${tomahawkSources} ${trans_outfile})
|
||||||
|
|
||||||
IF( BUILD_GUI )
|
IF( BUILD_GUI )
|
||||||
LIST(APPEND tomahawkHeaders ${tomahawkHeadersGui})
|
|
||||||
LIST(APPEND tomahawkSources ${tomahawkSourcesGui})
|
LIST(APPEND tomahawkSources ${tomahawkSourcesGui})
|
||||||
qt4_wrap_ui( tomahawkUI_H ${tomahawkUI} )
|
qt4_wrap_ui( tomahawkUI_H ${tomahawkUI} )
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
kde4_add_app_icon( tomahawkSources "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-*.png" )
|
kde4_add_app_icon( tomahawkSources "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-*.png" )
|
||||||
qt4_add_resources( RC_SRCS "../resources.qrc" )
|
qt4_add_resources( RC_SRCS "../resources.qrc" )
|
||||||
qt4_wrap_cpp( tomahawkMoc ${tomahawkHeaders} )
|
|
||||||
SET( final_src ${final_src} ${tomahawkUI_H} ${tomahawkMoc} ${tomahawkSources} ${RC_SRCS} )
|
SET( final_src ${final_src} ${tomahawkUI_H} ${tomahawkMoc} ${tomahawkSources} ${RC_SRCS} )
|
||||||
|
|
||||||
IF( UNIX AND NOT APPLE )
|
IF( UNIX AND NOT APPLE )
|
||||||
ADD_EXECUTABLE( tomahawk ${final_src} )
|
ADD_EXECUTABLE( tomahawk ${final_src} )
|
||||||
|
SET_TARGET_PROPERTIES(tomahawk PROPERTIES AUTOMOC TRUE)
|
||||||
ENDIF( UNIX AND NOT APPLE )
|
ENDIF( UNIX AND NOT APPLE )
|
||||||
IF( APPLE )
|
IF( APPLE )
|
||||||
ADD_EXECUTABLE( tomahawk MACOSX_BUNDLE ${final_src} )
|
ADD_EXECUTABLE( tomahawk MACOSX_BUNDLE ${final_src} )
|
||||||
SET_TARGET_PROPERTIES(tomahawk PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_BINARY_DIR}/Info.plist"
|
SET_TARGET_PROPERTIES(tomahawk PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_BINARY_DIR}/Info.plist")
|
||||||
)
|
SET_TARGET_PROPERTIES(tomahawk PROPERTIES AUTOMOC TRUE)
|
||||||
ENDIF( APPLE )
|
ENDIF( APPLE )
|
||||||
IF( WIN32 )
|
IF( WIN32 )
|
||||||
ADD_EXECUTABLE( tomahawk WIN32 ${final_src} )
|
ADD_EXECUTABLE( tomahawk WIN32 ${final_src} )
|
||||||
|
114
src/delegateconfigwrapper.cpp
Normal file
114
src/delegateconfigwrapper.cpp
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
|
*
|
||||||
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "delegateconfigwrapper.h"
|
||||||
|
|
||||||
|
|
||||||
|
DelegateConfigWrapper::DelegateConfigWrapper( QWidget* conf, const QString& title, QWidget* parent, Qt::WindowFlags flags )
|
||||||
|
: QDialog( parent, flags )
|
||||||
|
, m_widget( conf )
|
||||||
|
, m_deleted( false )
|
||||||
|
{
|
||||||
|
m_widget->setWindowFlags( Qt::Sheet );
|
||||||
|
#ifdef Q_WS_MAC
|
||||||
|
m_widget->setVisible( true );
|
||||||
|
#endif
|
||||||
|
setWindowTitle( title );
|
||||||
|
QVBoxLayout* v = new QVBoxLayout( this );
|
||||||
|
v->setContentsMargins( 0, 0, 0, 0 );
|
||||||
|
v->addWidget( m_widget );
|
||||||
|
|
||||||
|
m_buttons = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this );
|
||||||
|
m_okButton = m_buttons->button( QDialogButtonBox::Ok );
|
||||||
|
connect( m_buttons, SIGNAL( clicked( QAbstractButton*) ), this, SLOT( closed( QAbstractButton* ) ) );
|
||||||
|
connect( this, SIGNAL( rejected() ), this, SLOT( rejected() ) );
|
||||||
|
v->addWidget( m_buttons );
|
||||||
|
|
||||||
|
setLayout( v );
|
||||||
|
|
||||||
|
#ifdef Q_WS_MAC
|
||||||
|
setSizeGripEnabled( false );
|
||||||
|
setMinimumSize( sizeHint() );
|
||||||
|
setMaximumSize( sizeHint() ); // to remove the resize grip on osx this is the only way
|
||||||
|
|
||||||
|
if( conf->metaObject()->indexOfSignal( "sizeHintChanged()" ) > -1 )
|
||||||
|
connect( conf, SIGNAL( sizeHintChanged() ), this, SLOT( updateSizeHint() ) );
|
||||||
|
#else
|
||||||
|
m_widget->setVisible( true );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DelegateConfigWrapper::setShowDelete( bool del )
|
||||||
|
{
|
||||||
|
if ( del )
|
||||||
|
m_deleteButton = m_buttons->addButton( tr( "Delete Account" ), QDialogButtonBox::DestructiveRole );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DelegateConfigWrapper::toggleOkButton( bool dataError )
|
||||||
|
{
|
||||||
|
// if dataError is True we want to set the button enabled to false
|
||||||
|
m_okButton->setEnabled( !dataError );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DelegateConfigWrapper::closed( QAbstractButton* b )
|
||||||
|
{
|
||||||
|
// let the config widget live to see another day
|
||||||
|
layout()->removeWidget( m_widget );
|
||||||
|
m_widget->setParent( 0 );
|
||||||
|
m_widget->setVisible( false );
|
||||||
|
|
||||||
|
QDialogButtonBox* buttons = qobject_cast< QDialogButtonBox* >( sender() );
|
||||||
|
if ( buttons->standardButton( b ) == QDialogButtonBox::Ok )
|
||||||
|
done( QDialog::Accepted );
|
||||||
|
else if ( b == m_deleteButton )
|
||||||
|
{
|
||||||
|
m_deleted = true;
|
||||||
|
emit closedWithDelete();
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
done( QDialog::Rejected );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DelegateConfigWrapper::rejected()
|
||||||
|
{
|
||||||
|
layout()->removeWidget( m_widget );
|
||||||
|
m_widget->setParent( 0 );
|
||||||
|
m_widget->setVisible( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DelegateConfigWrapper::updateSizeHint()
|
||||||
|
{
|
||||||
|
hide();
|
||||||
|
setSizeGripEnabled( false );
|
||||||
|
setMinimumSize( sizeHint() );
|
||||||
|
setMaximumSize( sizeHint() );
|
||||||
|
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
@@ -28,91 +28,23 @@ class DelegateConfigWrapper : public QDialog
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DelegateConfigWrapper( QWidget* conf, const QString& title, QWidget* parent, Qt::WindowFlags flags = 0 ) : QDialog( parent, flags ), m_widget( conf ), m_deleted( false )
|
DelegateConfigWrapper( QWidget* conf, const QString& title, QWidget* parent, Qt::WindowFlags flags = 0 );
|
||||||
{
|
|
||||||
m_widget->setWindowFlags( Qt::Sheet );
|
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
m_widget->setVisible( true );
|
|
||||||
#endif
|
|
||||||
setWindowTitle( title );
|
|
||||||
QVBoxLayout* v = new QVBoxLayout( this );
|
|
||||||
v->setContentsMargins( 0, 0, 0, 0 );
|
|
||||||
v->addWidget( m_widget );
|
|
||||||
|
|
||||||
m_buttons = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this );
|
|
||||||
m_okButton = m_buttons->button( QDialogButtonBox::Ok );
|
|
||||||
connect( m_buttons, SIGNAL( clicked( QAbstractButton*) ), this, SLOT( closed( QAbstractButton* ) ) );
|
|
||||||
connect( this, SIGNAL( rejected() ), this, SLOT( rejected() ) );
|
|
||||||
v->addWidget( m_buttons );
|
|
||||||
|
|
||||||
setLayout( v );
|
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
setSizeGripEnabled( false );
|
|
||||||
setMinimumSize( sizeHint() );
|
|
||||||
setMaximumSize( sizeHint() ); // to remove the resize grip on osx this is the only way
|
|
||||||
|
|
||||||
if( conf->metaObject()->indexOfSignal( "sizeHintChanged()" ) > -1 )
|
|
||||||
connect( conf, SIGNAL( sizeHintChanged() ), this, SLOT( updateSizeHint() ) );
|
|
||||||
#else
|
|
||||||
m_widget->setVisible( true );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
~DelegateConfigWrapper() {}
|
~DelegateConfigWrapper() {}
|
||||||
|
|
||||||
void setShowDelete( bool del )
|
void setShowDelete( bool del );
|
||||||
{
|
|
||||||
if ( del )
|
|
||||||
m_deleteButton = m_buttons->addButton( tr( "Delete Account" ), QDialogButtonBox::DestructiveRole );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool deleted() const { return m_deleted; }
|
bool deleted() const { return m_deleted; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void toggleOkButton( bool dataError )
|
void toggleOkButton( bool dataError )
|
||||||
{
|
;
|
||||||
// if dataError is True we want to set the button enabled to false
|
void closed( QAbstractButton* b );
|
||||||
m_okButton->setEnabled( !dataError );
|
|
||||||
}
|
|
||||||
void closed( QAbstractButton* b )
|
|
||||||
{
|
|
||||||
// let the config widget live to see another day
|
|
||||||
layout()->removeWidget( m_widget );
|
|
||||||
m_widget->setParent( 0 );
|
|
||||||
m_widget->setVisible( false );
|
|
||||||
|
|
||||||
QDialogButtonBox* buttons = qobject_cast< QDialogButtonBox* >( sender() );
|
|
||||||
if( buttons->standardButton( b ) == QDialogButtonBox::Ok )
|
|
||||||
done( QDialog::Accepted );
|
|
||||||
else if ( b == m_deleteButton )
|
|
||||||
{
|
|
||||||
m_deleted = true;
|
|
||||||
emit closedWithDelete();
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
done( QDialog::Rejected );
|
|
||||||
}
|
|
||||||
|
|
||||||
// we get a rejected() signal emitted if the user presses escape (and no clicked() signal )
|
// we get a rejected() signal emitted if the user presses escape (and no clicked() signal )
|
||||||
void rejected()
|
void rejected();
|
||||||
{
|
|
||||||
layout()->removeWidget( m_widget );
|
|
||||||
m_widget->setParent( 0 );
|
|
||||||
m_widget->setVisible( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateSizeHint()
|
void updateSizeHint();
|
||||||
{
|
|
||||||
hide();
|
|
||||||
setSizeGripEnabled( false );
|
|
||||||
setMinimumSize( sizeHint() );
|
|
||||||
setMaximumSize( sizeHint() );
|
|
||||||
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void closedWithDelete();
|
void closedWithDelete();
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "tomahawkutilsgui.h"
|
#include "tomahawkutilsgui.h"
|
||||||
|
|
||||||
|
#include "logger.h"
|
||||||
#include <QtGui/QLayout>
|
#include <QtGui/QLayout>
|
||||||
#include <QtGui/QPainter>
|
#include <QtGui/QPainter>
|
||||||
#include <QtGui/QPixmap>
|
#include <QtGui/QPixmap>
|
||||||
@@ -36,7 +38,6 @@
|
|||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "logger.h"
|
|
||||||
|
|
||||||
namespace TomahawkUtils
|
namespace TomahawkUtils
|
||||||
{
|
{
|
||||||
@@ -360,4 +361,5 @@ defaultPixmap( ImageType type, ImageMode mode, const QSize& size )
|
|||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -50,6 +51,7 @@ namespace TomahawkUtils
|
|||||||
DLLEXPORT void setHeaderHeight( int height );
|
DLLEXPORT void setHeaderHeight( int height );
|
||||||
|
|
||||||
DLLEXPORT QPixmap defaultPixmap( ImageType type, ImageMode mode, const QSize& size = QSize( 0, 0 ) );
|
DLLEXPORT QPixmap defaultPixmap( ImageType type, ImageMode mode, const QSize& size = QSize( 0, 0 ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TOMAHAWKUTILSGUI_H
|
#endif // TOMAHAWKUTILSGUI_H
|
||||||
|
@@ -20,8 +20,6 @@
|
|||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "utils/tomahawkutilsgui.h"
|
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@@ -38,6 +36,8 @@
|
|||||||
#include "pipeline.h"
|
#include "pipeline.h"
|
||||||
#include "resolver.h"
|
#include "resolver.h"
|
||||||
#include "ExternalResolverGui.h"
|
#include "ExternalResolverGui.h"
|
||||||
|
#include "utils/tomahawkutilsgui.h"
|
||||||
|
#include "guihelpers.h"
|
||||||
#include "scanmanager.h"
|
#include "scanmanager.h"
|
||||||
#include "settingslistdelegate.h"
|
#include "settingslistdelegate.h"
|
||||||
#include "AccountDelegate.h"
|
#include "AccountDelegate.h"
|
||||||
@@ -343,61 +343,6 @@ SettingsDialog::accountsFilterChanged( int )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SettingsDialog::openAccountConfig( Account* account, bool showDelete )
|
|
||||||
{
|
|
||||||
if( account->configurationWidget() )
|
|
||||||
{
|
|
||||||
#ifndef Q_OS_MAC
|
|
||||||
DelegateConfigWrapper dialog( account->configurationWidget(), QString("%1 Configuration" ).arg( account->accountFriendlyName() ), this );
|
|
||||||
dialog.setShowDelete( showDelete );
|
|
||||||
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
|
||||||
int ret = dialog.exec();
|
|
||||||
if ( !watcher.isNull() && dialog.deleted() )
|
|
||||||
{
|
|
||||||
AccountManager::instance()->removeAccount( account );
|
|
||||||
}
|
|
||||||
else if( !watcher.isNull() && ret == QDialog::Accepted )
|
|
||||||
{
|
|
||||||
// send changed config to resolver
|
|
||||||
account->saveConfig();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// on osx a sheet needs to be non-modal
|
|
||||||
DelegateConfigWrapper* dialog = new DelegateConfigWrapper( account->configurationWidget(), QString("%1 Configuration" ).arg( account->accountFriendlyName() ), this, Qt::Sheet );
|
|
||||||
dialog->setShowDelete( showDelete );
|
|
||||||
dialog->setProperty( "accountplugin", QVariant::fromValue< QObject* >( account ) );
|
|
||||||
connect( dialog, SIGNAL( finished( int ) ), this, SLOT( accountConfigClosed( int ) ) );
|
|
||||||
connect( dialog, SIGNAL( closedWithDelete() ), this, SLOT( accountConfigDelete() ) );
|
|
||||||
|
|
||||||
dialog->show();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SettingsDialog::accountConfigClosed( int value )
|
|
||||||
{
|
|
||||||
if( value == QDialog::Accepted )
|
|
||||||
{
|
|
||||||
DelegateConfigWrapper* dialog = qobject_cast< DelegateConfigWrapper* >( sender() );
|
|
||||||
Account* account = qobject_cast< Account* >( dialog->property( "accountplugin" ).value< QObject* >() );
|
|
||||||
account->saveConfig();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SettingsDialog::accountConfigDelete()
|
|
||||||
{
|
|
||||||
DelegateConfigWrapper* dialog = qobject_cast< DelegateConfigWrapper* >( sender() );
|
|
||||||
Account* account = qobject_cast< Account* >( dialog->property( "accountplugin" ).value< QObject* >() );
|
|
||||||
Q_ASSERT( account );
|
|
||||||
AccountManager::instance()->removeAccount( account );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::openAccountFactoryConfig( AccountFactory* factory )
|
SettingsDialog::openAccountFactoryConfig( AccountFactory* factory )
|
||||||
{
|
{
|
||||||
@@ -437,89 +382,17 @@ SettingsDialog::openAccountFactoryConfig( AccountFactory* factory )
|
|||||||
void
|
void
|
||||||
SettingsDialog::createAccountFromFactory( AccountFactory* factory )
|
SettingsDialog::createAccountFromFactory( AccountFactory* factory )
|
||||||
{
|
{
|
||||||
#ifdef Q_WS_MAC
|
TomahawkUtils::createAccountFromFactory( factory, this );
|
||||||
// On mac we need to close the dialog we came from before showing another dialog, if we are b eing called from a dialog
|
|
||||||
if ( sender() )
|
|
||||||
{
|
|
||||||
Q_ASSERT( qobject_cast< AccountFactoryWrapper* >( sender() ) );
|
|
||||||
AccountFactoryWrapper* dialog = qobject_cast< AccountFactoryWrapper* >( sender() );
|
|
||||||
dialog->accept();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//if exited with OK, create it, if not, delete it immediately!
|
|
||||||
Account* account = factory->createAccount();
|
|
||||||
bool added = false;
|
|
||||||
if( account->configurationWidget() )
|
|
||||||
{
|
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
// on osx a sheet needs to be non-modal
|
|
||||||
DelegateConfigWrapper* dialog = new DelegateConfigWrapper( account->configurationWidget(), QString("%1 Config" ).arg( account->accountFriendlyName() ), this, Qt::Sheet );
|
|
||||||
dialog->setProperty( "accountplugin", QVariant::fromValue< QObject* >( account ) );
|
|
||||||
connect( dialog, SIGNAL( finished( int ) ), this, SLOT( accountCreateConfigClosed( int ) ) );
|
|
||||||
|
|
||||||
if( account->configurationWidget()->metaObject()->indexOfSignal( "dataError(bool)" ) > -1 )
|
|
||||||
connect( account->configurationWidget(), SIGNAL( dataError( bool ) ), dialog, SLOT( toggleOkButton( bool ) ), Qt::UniqueConnection );
|
|
||||||
|
|
||||||
dialog->show();
|
|
||||||
#else
|
|
||||||
DelegateConfigWrapper dialog( account->configurationWidget(), QString("%1 Config" ).arg( account->accountFriendlyName() ), this );
|
|
||||||
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
|
||||||
|
|
||||||
if( account->configurationWidget()->metaObject()->indexOfSignal( "dataError(bool)" ) > -1 )
|
|
||||||
connect( account->configurationWidget(), SIGNAL( dataError( bool ) ), &dialog, SLOT( toggleOkButton( bool ) ), Qt::UniqueConnection );
|
|
||||||
|
|
||||||
int ret = dialog.exec();
|
|
||||||
if( !watcher.isNull() && ret == QDialog::Accepted ) // send changed config to account
|
|
||||||
added = true;
|
|
||||||
else // canceled, delete it
|
|
||||||
added = false;
|
|
||||||
|
|
||||||
handleAccountAdded( account, added );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// no config, so just add it
|
|
||||||
added = true;
|
|
||||||
handleAccountAdded( account, added );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::accountCreateConfigClosed( int finished )
|
SettingsDialog::openAccountConfig( Account* account, bool showDelete )
|
||||||
{
|
{
|
||||||
DelegateConfigWrapper* dialog = qobject_cast< DelegateConfigWrapper* >( sender() );
|
TomahawkUtils::openAccountConfig( account, this, showDelete );
|
||||||
Account* account = qobject_cast< Account* >( dialog->property( "accountplugin" ).value< QObject* >() );
|
|
||||||
Q_ASSERT( account );
|
|
||||||
|
|
||||||
bool added = ( finished == QDialog::Accepted );
|
|
||||||
|
|
||||||
handleAccountAdded( account, added );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SettingsDialog::handleAccountAdded( Account* account, bool added )
|
|
||||||
{
|
|
||||||
if ( added )
|
|
||||||
{
|
|
||||||
account->setEnabled( true );
|
|
||||||
account->setAutoConnect( true );
|
|
||||||
account->saveConfig();
|
|
||||||
|
|
||||||
TomahawkSettings::instance()->addAccount( account->accountId() );
|
|
||||||
AccountManager::instance()->addAccount( account );
|
|
||||||
AccountManager::instance()->hookupAndEnable( account );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// user pressed cancel
|
|
||||||
delete account;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::installFromFile()
|
SettingsDialog::installFromFile()
|
||||||
|
@@ -89,12 +89,8 @@ private slots:
|
|||||||
void accountsFilterChanged( int );
|
void accountsFilterChanged( int );
|
||||||
|
|
||||||
void createAccountFromFactory( Tomahawk::Accounts::AccountFactory* );
|
void createAccountFromFactory( Tomahawk::Accounts::AccountFactory* );
|
||||||
|
|
||||||
void openAccountConfig( Tomahawk::Accounts::Account*, bool showDelete = false );
|
void openAccountConfig( Tomahawk::Accounts::Account*, bool showDelete = false );
|
||||||
void openAccountFactoryConfig( Tomahawk::Accounts::AccountFactory* );
|
void openAccountFactoryConfig( Tomahawk::Accounts::AccountFactory* );
|
||||||
void accountConfigClosed( int value );
|
|
||||||
void accountConfigDelete();
|
|
||||||
void accountCreateConfigClosed( int value );
|
|
||||||
|
|
||||||
void installFromFile();
|
void installFromFile();
|
||||||
void scrollTo( const QModelIndex& );
|
void scrollTo( const QModelIndex& );
|
||||||
@@ -108,7 +104,6 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void createIcons();
|
void createIcons();
|
||||||
void handleAccountAdded( Tomahawk::Accounts::Account* p, bool added );
|
|
||||||
|
|
||||||
Ui_StackedSettingsDialog* ui;
|
Ui_StackedSettingsDialog* ui;
|
||||||
|
|
||||||
|
172
src/utils/guihelpers.cpp
Normal file
172
src/utils/guihelpers.cpp
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
|
*
|
||||||
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "guihelpers.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "accounts/Account.h"
|
||||||
|
#include "accounts/AccountManager.h"
|
||||||
|
#include "delegateconfigwrapper.h"
|
||||||
|
|
||||||
|
namespace TomahawkUtils
|
||||||
|
{
|
||||||
|
|
||||||
|
void
|
||||||
|
handleAccountAdded( Tomahawk::Accounts::Account* account, bool added )
|
||||||
|
{
|
||||||
|
if ( added )
|
||||||
|
{
|
||||||
|
account->setEnabled( true );
|
||||||
|
account->setAutoConnect( true );
|
||||||
|
account->saveConfig();
|
||||||
|
|
||||||
|
TomahawkSettings::instance()->addAccount( account->accountId() );
|
||||||
|
Tomahawk::Accounts::AccountManager::instance()->addAccount( account );
|
||||||
|
Tomahawk::Accounts::AccountManager::instance()->hookupAndEnable( account );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// user pressed cancel
|
||||||
|
delete account;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class UtilsObject : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
UtilsObject( DelegateConfigWrapper* w ) : QObject( w ), m_w( w ) {}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void
|
||||||
|
accountCreateConfigClosed( int ret )
|
||||||
|
{
|
||||||
|
Tomahawk::Accounts::Account* account = qobject_cast< Tomahawk::Accounts::Account* >( m_w->property( "accountplugin" ).value< QObject* >() );
|
||||||
|
Q_ASSERT( account );
|
||||||
|
|
||||||
|
bool added = ( ret == QDialog::Accepted );
|
||||||
|
|
||||||
|
handleAccountAdded( account, added );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
accountConfigClosed( int ret )
|
||||||
|
{
|
||||||
|
if( ret == QDialog::Accepted )
|
||||||
|
{
|
||||||
|
Tomahawk::Accounts::Account* account = qobject_cast< Tomahawk::Accounts::Account* >( m_w->property( "accountplugin" ).value< QObject* >() );
|
||||||
|
account->saveConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
accountConfigDelete()
|
||||||
|
{
|
||||||
|
Tomahawk::Accounts::Account* account = qobject_cast< Tomahawk::Accounts::Account* >( m_w->property( "accountplugin" ).value< QObject* >() );
|
||||||
|
Q_ASSERT( account );
|
||||||
|
Tomahawk::Accounts::AccountManager::instance()->removeAccount( account );
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
DelegateConfigWrapper* m_w;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
createAccountFromFactory( Tomahawk::Accounts::AccountFactory* factory, QWidget* parent )
|
||||||
|
{
|
||||||
|
//if exited with OK, create it, if not, delete it immediately!
|
||||||
|
Tomahawk::Accounts::Account* account = factory->createAccount();
|
||||||
|
bool added = false;
|
||||||
|
if( account->configurationWidget() )
|
||||||
|
{
|
||||||
|
#ifdef Q_WS_MAC
|
||||||
|
// on osx a sheet needs to be non-modal
|
||||||
|
DelegateConfigWrapper* dialog = new DelegateConfigWrapper( account->configurationWidget(), QString("%1 Config" ).arg( account->accountFriendlyName() ), parent, Qt::Sheet );
|
||||||
|
dialog->setProperty( "accountplugin", QVariant::fromValue< QObject* >( account ) );
|
||||||
|
|
||||||
|
UtilsObject* obj = new UtilsObject( dialog );
|
||||||
|
QObject::connect( dialog, SIGNAL( finished( int ) ), obj, SLOT( accountCreateConfigClosed( int ) ) );
|
||||||
|
|
||||||
|
if( account->configurationWidget()->metaObject()->indexOfSignal( "dataError(bool)" ) > -1 )
|
||||||
|
QObject::connect( account->configurationWidget(), SIGNAL( dataError( bool ) ), dialog, SLOT( toggleOkButton( bool ) ), Qt::UniqueConnection );
|
||||||
|
|
||||||
|
dialog->show();
|
||||||
|
#else
|
||||||
|
DelegateConfigWrapper dialog( account->configurationWidget(), QString("%1 Config" ).arg( account->accountFriendlyName() ), parent );
|
||||||
|
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
||||||
|
|
||||||
|
if( account->configurationWidget()->metaObject()->indexOfSignal( "dataError(bool)" ) > -1 )
|
||||||
|
QObject::connect( account->configurationWidget(), SIGNAL( dataError( bool ) ), &dialog, SLOT( toggleOkButton( bool ) ), Qt::UniqueConnection );
|
||||||
|
|
||||||
|
int ret = dialog.exec();
|
||||||
|
if( !watcher.isNull() && ret == QDialog::Accepted ) // send changed config to account
|
||||||
|
added = true;
|
||||||
|
else // canceled, delete it
|
||||||
|
added = false;
|
||||||
|
|
||||||
|
handleAccountAdded( account, added );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// no config, so just add it
|
||||||
|
added = true;
|
||||||
|
handleAccountAdded( account, added );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
openAccountConfig( Tomahawk::Accounts::Account* account, QWidget* parent, bool showDelete )
|
||||||
|
{
|
||||||
|
if( account->configurationWidget() )
|
||||||
|
{
|
||||||
|
#ifndef Q_OS_MAC
|
||||||
|
DelegateConfigWrapper dialog( account->configurationWidget(), QString("%1 Configuration" ).arg( account->accountFriendlyName() ), parent );
|
||||||
|
dialog.setShowDelete( showDelete );
|
||||||
|
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
||||||
|
int ret = dialog.exec();
|
||||||
|
if ( !watcher.isNull() && dialog.deleted() )
|
||||||
|
{
|
||||||
|
Tomahawk::Accounts::AccountManager::instance()->removeAccount( account );
|
||||||
|
}
|
||||||
|
else if( !watcher.isNull() && ret == QDialog::Accepted )
|
||||||
|
{
|
||||||
|
// send changed config to resolver
|
||||||
|
account->saveConfig();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// on osx a sheet needs to be non-modal
|
||||||
|
DelegateConfigWrapper* dialog = new DelegateConfigWrapper( account->configurationWidget(), QString("%1 Configuration" ).arg( account->accountFriendlyName() ), parent, Qt::Sheet );
|
||||||
|
dialog->setShowDelete( showDelete );
|
||||||
|
dialog->setProperty( "accountplugin", QVariant::fromValue< QObject* >( account ) );
|
||||||
|
UtilsObject* obj = new UtilsObject( dialog );
|
||||||
|
|
||||||
|
QObject::connect( dialog, SIGNAL( finished( int ) ), obj, SLOT( accountConfigClosed( int ) ) );
|
||||||
|
QObject::connect( dialog, SIGNAL( closedWithDelete() ), obj, SLOT( accountConfigDelete() ) );
|
||||||
|
|
||||||
|
dialog->show();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace TomahawkUtils
|
||||||
|
|
||||||
|
#include "guihelpers.moc"
|
38
src/utils/guihelpers.h
Normal file
38
src/utils/guihelpers.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
|
*
|
||||||
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TOMAHAWK_GUI_HELPERS_H
|
||||||
|
#define TOMAHAWK_GUI_HELPERS_H
|
||||||
|
|
||||||
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
class QWidget;
|
||||||
|
namespace Tomahawk {
|
||||||
|
namespace Accounts {
|
||||||
|
class AccountFactory;
|
||||||
|
class Account;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace TomahawkUtils
|
||||||
|
{
|
||||||
|
DLLEXPORT void createAccountFromFactory( Tomahawk::Accounts::AccountFactory*, QWidget* parent );
|
||||||
|
DLLEXPORT void openAccountConfig( Tomahawk::Accounts::Account*, QWidget* parent, bool showDelete = false );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user