mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 23:26:40 +02:00
* Remember last used script path and store it.
This commit is contained in:
@@ -849,6 +849,20 @@ TomahawkSettings::setEnabledScriptResolvers( const QStringList& resolvers )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
TomahawkSettings::scriptDefaultPath() const
|
||||||
|
{
|
||||||
|
return value( "script/defaultpath", QDir::homePath() ).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkSettings::setScriptDefaultPath( const QString& path )
|
||||||
|
{
|
||||||
|
setValue( "script/defaultpath", path );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TomahawkSettings::nowPlayingEnabled() const
|
TomahawkSettings::nowPlayingEnabled() const
|
||||||
{
|
{
|
||||||
|
@@ -184,6 +184,9 @@ public:
|
|||||||
QStringList enabledScriptResolvers() const;
|
QStringList enabledScriptResolvers() const;
|
||||||
void setEnabledScriptResolvers( const QStringList& resolvers );
|
void setEnabledScriptResolvers( const QStringList& resolvers );
|
||||||
|
|
||||||
|
QString scriptDefaultPath() const;
|
||||||
|
void setScriptDefaultPath( const QString& path );
|
||||||
|
|
||||||
// Now-Playing Settings
|
// Now-Playing Settings
|
||||||
// For now, just Adium. Soon, the world!
|
// For now, just Adium. Soon, the world!
|
||||||
bool nowPlayingEnabled() const; // false by default
|
bool nowPlayingEnabled() const; // false by default
|
||||||
|
@@ -240,6 +240,7 @@ SettingsDialog::~SettingsDialog()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::serventReady()
|
SettingsDialog::serventReady()
|
||||||
{
|
{
|
||||||
@@ -248,6 +249,7 @@ SettingsDialog::serventReady()
|
|||||||
ui->removeSipButton->setEnabled( true );
|
ui->removeSipButton->setEnabled( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::createIcons()
|
SettingsDialog::createIcons()
|
||||||
{
|
{
|
||||||
@@ -512,10 +514,13 @@ SettingsDialog::onLastFmFinished()
|
|||||||
void
|
void
|
||||||
SettingsDialog::addScriptResolver()
|
SettingsDialog::addScriptResolver()
|
||||||
{
|
{
|
||||||
QString resolver = QFileDialog::getOpenFileName( this, tr( "Load script resolver file" ), qApp->applicationDirPath() );
|
QString resolver = QFileDialog::getOpenFileName( this, tr( "Load script resolver file" ), TomahawkSettings::instance()->scriptDefaultPath() );
|
||||||
if( !resolver.isEmpty() ) {
|
if( !resolver.isEmpty() )
|
||||||
|
{
|
||||||
TomahawkApp::instance()->enableScriptResolver( resolver );
|
TomahawkApp::instance()->enableScriptResolver( resolver );
|
||||||
m_resolversModel->addResolver( resolver, true );
|
m_resolversModel->addResolver( resolver, true );
|
||||||
|
QFileInfo resolverAbsoluteFilePath = resolver;
|
||||||
|
TomahawkSettings::instance()->setScriptDefaultPath( resolverAbsoluteFilePath.absolutePath() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -524,7 +529,8 @@ void
|
|||||||
SettingsDialog::removeScriptResolver()
|
SettingsDialog::removeScriptResolver()
|
||||||
{
|
{
|
||||||
// only one selection
|
// only one selection
|
||||||
if( !ui->scriptList->selectionModel()->selectedIndexes().isEmpty() ) {
|
if( !ui->scriptList->selectionModel()->selectedIndexes().isEmpty() )
|
||||||
|
{
|
||||||
QString resolver = ui->scriptList->selectionModel()->selectedIndexes().first().data( ResolversModel::ResolverPath ).toString();
|
QString resolver = ui->scriptList->selectionModel()->selectedIndexes().first().data( ResolversModel::ResolverPath ).toString();
|
||||||
m_resolversModel->removeResolver( resolver );
|
m_resolversModel->removeResolver( resolver );
|
||||||
|
|
||||||
@@ -532,26 +538,33 @@ SettingsDialog::removeScriptResolver()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::scriptSelectionChanged()
|
SettingsDialog::scriptSelectionChanged()
|
||||||
{
|
{
|
||||||
if( !ui->scriptList->selectionModel()->selectedIndexes().isEmpty() ) {
|
if( !ui->scriptList->selectionModel()->selectedIndexes().isEmpty() )
|
||||||
|
{
|
||||||
ui->removeScript->setEnabled( true );
|
ui->removeScript->setEnabled( true );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
ui->removeScript->setEnabled( false );
|
ui->removeScript->setEnabled( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::openResolverConfig( const QString& resolver )
|
SettingsDialog::openResolverConfig( const QString& resolver )
|
||||||
{
|
{
|
||||||
Tomahawk::ExternalResolver* r = TomahawkApp::instance()->resolverForPath( resolver );
|
Tomahawk::ExternalResolver* r = TomahawkApp::instance()->resolverForPath( resolver );
|
||||||
if( r && r->configUI() ) {
|
if( r && r->configUI() )
|
||||||
|
{
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
DelegateConfigWrapper dialog( r->configUI(), "Resolver Configuration", this );
|
DelegateConfigWrapper dialog( r->configUI(), "Resolver Configuration", this );
|
||||||
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
||||||
int ret = dialog.exec();
|
int ret = dialog.exec();
|
||||||
if( !watcher.isNull() && ret == QDialog::Accepted ) {
|
if( !watcher.isNull() && ret == QDialog::Accepted )
|
||||||
|
{
|
||||||
// send changed config to resolver
|
// send changed config to resolver
|
||||||
r->saveConfig();
|
r->saveConfig();
|
||||||
}
|
}
|
||||||
@@ -567,16 +580,19 @@ SettingsDialog::openResolverConfig( const QString& resolver )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::resolverConfigClosed( int value )
|
SettingsDialog::resolverConfigClosed( int value )
|
||||||
{
|
{
|
||||||
if( value == QDialog::Accepted ) {
|
if( value == QDialog::Accepted )
|
||||||
|
{
|
||||||
DelegateConfigWrapper* dialog = qobject_cast< DelegateConfigWrapper* >( sender() );
|
DelegateConfigWrapper* dialog = qobject_cast< DelegateConfigWrapper* >( sender() );
|
||||||
Tomahawk::ExternalResolver* r = qobject_cast< Tomahawk::ExternalResolver* >( dialog->property( "resolver" ).value< QObject* >() );
|
Tomahawk::ExternalResolver* r = qobject_cast< Tomahawk::ExternalResolver* >( dialog->property( "resolver" ).value< QObject* >() );
|
||||||
r->saveConfig();
|
r->saveConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::sipItemClicked( const QModelIndex& item )
|
SettingsDialog::sipItemClicked( const QModelIndex& item )
|
||||||
{
|
{
|
||||||
@@ -589,15 +605,18 @@ SettingsDialog::sipItemClicked( const QModelIndex& item )
|
|||||||
sipFactoryClicked( qobject_cast<SipPluginFactory* >( item.data( SipModel::SipPluginFactoryData ).value< QObject* >() ) );
|
sipFactoryClicked( qobject_cast<SipPluginFactory* >( item.data( SipModel::SipPluginFactoryData ).value< QObject* >() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::openSipConfig( SipPlugin* p )
|
SettingsDialog::openSipConfig( SipPlugin* p )
|
||||||
{
|
{
|
||||||
if( p->configWidget() ) {
|
if( p->configWidget() )
|
||||||
|
{
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
DelegateConfigWrapper dialog( p->configWidget(), QString("%1 Configuration" ).arg( p->friendlyName() ), this );
|
DelegateConfigWrapper dialog( p->configWidget(), QString("%1 Configuration" ).arg( p->friendlyName() ), this );
|
||||||
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
||||||
int ret = dialog.exec();
|
int ret = dialog.exec();
|
||||||
if( !watcher.isNull() && ret == QDialog::Accepted ) {
|
if( !watcher.isNull() && ret == QDialog::Accepted )
|
||||||
|
{
|
||||||
// send changed config to resolver
|
// send changed config to resolver
|
||||||
p->saveConfig();
|
p->saveConfig();
|
||||||
}
|
}
|
||||||
@@ -616,13 +635,15 @@ SettingsDialog::openSipConfig( SipPlugin* p )
|
|||||||
void
|
void
|
||||||
SettingsDialog::sipConfigClosed( int value )
|
SettingsDialog::sipConfigClosed( int value )
|
||||||
{
|
{
|
||||||
if( value == QDialog::Accepted ) {
|
if( value == QDialog::Accepted )
|
||||||
|
{
|
||||||
DelegateConfigWrapper* dialog = qobject_cast< DelegateConfigWrapper* >( sender() );
|
DelegateConfigWrapper* dialog = qobject_cast< DelegateConfigWrapper* >( sender() );
|
||||||
SipPlugin* p = qobject_cast< SipPlugin* >( dialog->property( "sipplugin" ).value< QObject* >() );
|
SipPlugin* p = qobject_cast< SipPlugin* >( dialog->property( "sipplugin" ).value< QObject* >() );
|
||||||
p->saveConfig();
|
p->saveConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::factoryActionTriggered( bool )
|
SettingsDialog::factoryActionTriggered( bool )
|
||||||
{
|
{
|
||||||
@@ -642,8 +663,8 @@ SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
|||||||
//if exited with OK, create it, if not, delete it immediately!
|
//if exited with OK, create it, if not, delete it immediately!
|
||||||
SipPlugin* p = factory->createPlugin();
|
SipPlugin* p = factory->createPlugin();
|
||||||
bool added = false;
|
bool added = false;
|
||||||
if( p->configWidget() ) {
|
if( p->configWidget() )
|
||||||
|
{
|
||||||
#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( p->configWidget(), QString("%1 Config" ).arg( p->friendlyName() ), this, Qt::Sheet );
|
DelegateConfigWrapper* dialog = new DelegateConfigWrapper( p->configWidget(), QString("%1 Config" ).arg( p->friendlyName() ), this, Qt::Sheet );
|
||||||
@@ -657,7 +678,8 @@ SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
|||||||
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
||||||
connect( p, SIGNAL( dataError( bool ) ), &dialog, SLOT( toggleOkButton( bool ) ) );
|
connect( p, SIGNAL( dataError( bool ) ), &dialog, SLOT( toggleOkButton( bool ) ) );
|
||||||
int ret = dialog.exec();
|
int ret = dialog.exec();
|
||||||
if( !watcher.isNull() && ret == QDialog::Accepted ) {
|
if( !watcher.isNull() && ret == QDialog::Accepted )
|
||||||
|
{
|
||||||
// send changed config to resolver
|
// send changed config to resolver
|
||||||
p->saveConfig();
|
p->saveConfig();
|
||||||
|
|
||||||
@@ -666,14 +688,17 @@ SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
|||||||
SipHandler::instance()->addSipPlugin( p );
|
SipHandler::instance()->addSipPlugin( p );
|
||||||
|
|
||||||
added = true;
|
added = true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// canceled, delete it
|
// canceled, delete it
|
||||||
added = false;
|
added = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSipPluginAdded( p, added );
|
handleSipPluginAdded( p, added );
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
// no config, so just add it
|
// no config, so just add it
|
||||||
added = true;
|
added = true;
|
||||||
TomahawkSettings::instance()->addSipPlugin( p->pluginId() );
|
TomahawkSettings::instance()->addSipPlugin( p->pluginId() );
|
||||||
@@ -681,9 +706,9 @@ SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
|||||||
|
|
||||||
handleSipPluginAdded( p, added );
|
handleSipPluginAdded( p, added );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::sipCreateConfigClosed( int finished )
|
SettingsDialog::sipCreateConfigClosed( int finished )
|
||||||
{
|
{
|
||||||
@@ -692,7 +717,8 @@ SettingsDialog::sipCreateConfigClosed( int finished )
|
|||||||
Q_ASSERT( p );
|
Q_ASSERT( p );
|
||||||
|
|
||||||
bool added = false;
|
bool added = false;
|
||||||
if( finished == QDialog::Accepted ) {
|
if( finished == QDialog::Accepted )
|
||||||
|
{
|
||||||
|
|
||||||
p->saveConfig();
|
p->saveConfig();
|
||||||
TomahawkSettings::instance()->addSipPlugin( p->pluginId() );
|
TomahawkSettings::instance()->addSipPlugin( p->pluginId() );
|
||||||
@@ -709,7 +735,8 @@ void
|
|||||||
SettingsDialog::handleSipPluginAdded( SipPlugin* p, bool added )
|
SettingsDialog::handleSipPluginAdded( SipPlugin* p, bool added )
|
||||||
{
|
{
|
||||||
SipPluginFactory* f = SipHandler::instance()->factoryFromPlugin( p );
|
SipPluginFactory* f = SipHandler::instance()->factoryFromPlugin( p );
|
||||||
if( added && f && f->isUnique() ) {
|
if( added && f && f->isUnique() )
|
||||||
|
{
|
||||||
// remove from actions list
|
// remove from actions list
|
||||||
QAction* toremove = 0;
|
QAction* toremove = 0;
|
||||||
foreach( QAction* a, ui->addSipButton->actions() )
|
foreach( QAction* a, ui->addSipButton->actions() )
|
||||||
@@ -722,7 +749,9 @@ SettingsDialog::handleSipPluginAdded( SipPlugin* p, bool added )
|
|||||||
}
|
}
|
||||||
if( toremove )
|
if( toremove )
|
||||||
ui->addSipButton->removeAction( toremove );
|
ui->addSipButton->removeAction( toremove );
|
||||||
} else if( added == false ) { // user pressed cancel
|
}
|
||||||
|
else if( added == false )
|
||||||
|
{ // user pressed cancel
|
||||||
delete p;
|
delete p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -743,6 +772,7 @@ SettingsDialog::sipContextMenuRequest( const QPoint& p )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::sipPluginRowDeleted( bool )
|
SettingsDialog::sipPluginRowDeleted( bool )
|
||||||
{
|
{
|
||||||
@@ -750,6 +780,7 @@ SettingsDialog::sipPluginRowDeleted( bool )
|
|||||||
SipHandler::instance()->removeSipPlugin( p );
|
SipHandler::instance()->removeSipPlugin( p );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::sipPluginDeleted( bool )
|
SettingsDialog::sipPluginDeleted( bool )
|
||||||
{
|
{
|
||||||
@@ -819,6 +850,7 @@ ProxyDialog::ProxyDialog( QWidget *parent )
|
|||||||
connect( ui->typeBox, SIGNAL( currentIndexChanged( int ) ), SLOT( proxyTypeChangedSlot( int ) ) );
|
connect( ui->typeBox, SIGNAL( currentIndexChanged( int ) ), SLOT( proxyTypeChangedSlot( int ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ProxyDialog::proxyTypeChangedSlot( int index )
|
ProxyDialog::proxyTypeChangedSlot( int index )
|
||||||
{
|
{
|
||||||
@@ -842,6 +874,7 @@ ProxyDialog::proxyTypeChangedSlot( int index )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ProxyDialog::saveSettings()
|
ProxyDialog::saveSettings()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user