mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-18 23:09:42 +01:00
Merge TomahawkSettings and TomahawkSettingsGui
This commit is contained in:
parent
68a225eeaa
commit
69530a4dd0
@ -19,7 +19,7 @@
|
||||
#include "AtticaManager.h"
|
||||
|
||||
#include "utils/TomahawkUtils.h"
|
||||
#include "TomahawkSettingsGui.h"
|
||||
#include "TomahawkSettings.h"
|
||||
#include "Pipeline.h"
|
||||
#include "Source.h"
|
||||
#include "config.h"
|
||||
@ -255,7 +255,7 @@ AtticaManager::uploadRating( const Content& c )
|
||||
}
|
||||
}
|
||||
|
||||
TomahawkSettingsGui::instanceGui()->setAtticaResolverStates( m_resolverStates );
|
||||
TomahawkSettings::instance()->setAtticaResolverStates( m_resolverStates );
|
||||
|
||||
PostJob* job = m_resolverProvider.voteForContent( c.id(), (uint)c.rating() );
|
||||
connect( job, SIGNAL( finished( Attica::BaseJob* ) ), job, SLOT( deleteLater() ) );
|
||||
@ -330,7 +330,7 @@ AtticaManager::providerAdded( const Provider& provider )
|
||||
m_resolverProvider = provider;
|
||||
m_resolvers.clear();
|
||||
|
||||
m_resolverStates = TomahawkSettingsGui::instanceGui()->atticaResolverStates();
|
||||
m_resolverStates = TomahawkSettings::instance()->atticaResolverStates();
|
||||
|
||||
ListJob<Category>* job = m_resolverProvider.requestCategories();
|
||||
connect( job, SIGNAL( finished( Attica::BaseJob* ) ), this, SLOT( categoriesReturned( Attica::BaseJob* ) ) );
|
||||
@ -382,7 +382,7 @@ AtticaManager::resolversList( BaseJob* j )
|
||||
// Uh oh
|
||||
qWarning() << "Found attica resolver marked as installed that didn't exist on disk! Setting to uninstalled: " << rId << dir.absolutePath();
|
||||
m_resolverStates[ rId ].state = Uninstalled;
|
||||
TomahawkSettingsGui::instanceGui()->setAtticaResolverState( rId, Uninstalled );
|
||||
TomahawkSettings::instance()->setAtticaResolverState( rId, Uninstalled );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -708,7 +708,7 @@ AtticaManager::payloadFetched()
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << "Setting installed state to resolver:" << resolverId;
|
||||
m_resolverStates[ resolverId ].state = Installed;
|
||||
TomahawkSettingsGui::instanceGui()->setAtticaResolverStates( m_resolverStates );
|
||||
TomahawkSettings::instance()->setAtticaResolverStates( m_resolverStates );
|
||||
emit resolverInstalled( resolverId );
|
||||
emit resolverStateChanged( resolverId );
|
||||
}
|
||||
@ -739,7 +739,7 @@ AtticaManager::uninstallResolver( const QString& pathToResolver )
|
||||
m_resolverStates[ atticaId ].state = Uninstalled;
|
||||
delete m_resolverStates[ resolver.id() ].pixmap;
|
||||
m_resolverStates[ atticaId ].pixmap = 0;
|
||||
TomahawkSettingsGui::instanceGui()->setAtticaResolverState( atticaId, Uninstalled );
|
||||
TomahawkSettings::instance()->setAtticaResolverState( atticaId, Uninstalled );
|
||||
|
||||
doResolverRemove( atticaId );
|
||||
}
|
||||
@ -757,7 +757,7 @@ AtticaManager::uninstallResolver( const Content& resolver )
|
||||
emit resolverStateChanged( resolver.id() );
|
||||
|
||||
m_resolverStates[ resolver.id() ].state = Uninstalled;
|
||||
TomahawkSettingsGui::instanceGui()->setAtticaResolverState( resolver.id(), Uninstalled );
|
||||
TomahawkSettings::instance()->setAtticaResolverState( resolver.id(), Uninstalled );
|
||||
}
|
||||
|
||||
delete m_resolverStates[ resolver.id() ].pixmap;
|
||||
|
@ -22,7 +22,6 @@ set( libGuiSources
|
||||
ViewPagePlugin.cpp
|
||||
ViewManager.cpp
|
||||
LatchManager.cpp
|
||||
TomahawkSettingsGui.cpp
|
||||
|
||||
context/ContextPage.cpp
|
||||
context/ContextWidget.cpp
|
||||
|
@ -35,9 +35,12 @@
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
||||
#include <qtkeychain/keychain.h>
|
||||
#include <QDesktopServices>
|
||||
#else
|
||||
#include <qt5keychain/keychain.h>
|
||||
#include <QStandardPaths>
|
||||
#endif
|
||||
|
||||
#include <QDir>
|
||||
|
||||
using namespace Tomahawk;
|
||||
@ -705,7 +708,11 @@ TomahawkSettings::infoSystemCacheVersion() const
|
||||
QString
|
||||
TomahawkSettings::storageCacheLocation() const
|
||||
{
|
||||
return QDir::tempPath() + "/tomahawk/";
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
return QStandardPaths::writableLocation( QStandardPaths::CacheLocation );
|
||||
#else
|
||||
return QDesktopServices::storageLocation( QDesktopServices::CacheLocation );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -714,8 +721,10 @@ TomahawkSettings::scannerPaths() const
|
||||
{
|
||||
QString musicLocation;
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
musicLocation = QDir::homePath() + QLatin1String("/Music");
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
musicLocation = QStandardPaths::writableLocation( QStandardPaths::MusicLocation );
|
||||
#else
|
||||
musicLocation = QDesktopServices::storageLocation( QDesktopServices::MusicLocation );
|
||||
#endif
|
||||
|
||||
return value( "scanner/paths", musicLocation ).toStringList();
|
||||
@ -1597,3 +1606,40 @@ TomahawkSettings::registerCustomSettingsHandlers()
|
||||
qRegisterMetaType< AtticaManager::StateHash >( "AtticaManager::StateHash" );
|
||||
qRegisterMetaTypeStreamOperators< AtticaManager::StateHash >( "AtticaManager::StateHash" );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::setAtticaResolverState( const QString& resolver, AtticaManager::ResolverState state )
|
||||
{
|
||||
AtticaManager::StateHash resolvers = value( "script/atticaresolverstates" ).value< AtticaManager::StateHash >();
|
||||
AtticaManager::Resolver r = resolvers.value( resolver );
|
||||
r.state = state;
|
||||
resolvers.insert( resolver, r );
|
||||
setValue( "script/atticaresolverstates", QVariant::fromValue< AtticaManager::StateHash >( resolvers ) );
|
||||
|
||||
sync();
|
||||
}
|
||||
|
||||
|
||||
AtticaManager::StateHash
|
||||
TomahawkSettings::atticaResolverStates() const
|
||||
{
|
||||
return value( "script/atticaresolverstates" ).value< AtticaManager::StateHash >();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::setAtticaResolverStates( const AtticaManager::StateHash states )
|
||||
{
|
||||
setValue( "script/atticaresolverstates", QVariant::fromValue< AtticaManager::StateHash >( states ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::removeAtticaResolverState ( const QString& resolver )
|
||||
{
|
||||
AtticaManager::StateHash resolvers = value( "script/atticaresolverstates" ).value< AtticaManager::StateHash >();
|
||||
resolvers.remove( resolver );
|
||||
setValue( "script/atticaresolverstates", QVariant::fromValue< AtticaManager::StateHash >( resolvers ) );
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,9 @@ public:
|
||||
void applyChanges() { emit changed(); }
|
||||
|
||||
/// General settings
|
||||
virtual QString storageCacheLocation() const;
|
||||
QString storageCacheLocation() const;
|
||||
|
||||
virtual QStringList scannerPaths() const; /// QDesktopServices::MusicLocation in TomahawkSettingsGui
|
||||
QStringList scannerPaths() const; /// QDesktopServices::MusicLocation in TomahawkSettingsGui
|
||||
void setScannerPaths( const QStringList& paths );
|
||||
bool hasScannerPaths() const;
|
||||
uint scannerTime() const;
|
||||
@ -226,6 +226,13 @@ public:
|
||||
void setLastChartIds( const QMap<QString, QVariant>& ids );
|
||||
QMap<QString, QVariant> lastChartIds();
|
||||
|
||||
AtticaManager::StateHash atticaResolverStates() const;
|
||||
void setAtticaResolverStates( const AtticaManager::StateHash states );
|
||||
|
||||
void setAtticaResolverState( const QString& resolver, AtticaManager::ResolverState state );
|
||||
void removeAtticaResolverState( const QString& resolver );
|
||||
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
void recentlyPlayedPlaylistAdded( const QString& playlistId, int sourceId );
|
||||
|
@ -1,107 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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 "TomahawkSettingsGui.h"
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
#include <QStandardPaths>
|
||||
#else
|
||||
#include <QDesktopServices>
|
||||
#endif
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
TomahawkSettingsGui*
|
||||
TomahawkSettingsGui::instanceGui()
|
||||
{
|
||||
return qobject_cast< TomahawkSettingsGui* >(TomahawkSettings::instance());
|
||||
}
|
||||
|
||||
|
||||
TomahawkSettingsGui::TomahawkSettingsGui( QObject* parent )
|
||||
: TomahawkSettings( parent )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TomahawkSettingsGui::~TomahawkSettingsGui()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
TomahawkSettingsGui::storageCacheLocation() const
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
return QStandardPaths::writableLocation( QStandardPaths::CacheLocation );
|
||||
#else
|
||||
return QDesktopServices::storageLocation( QDesktopServices::CacheLocation );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QStringList
|
||||
TomahawkSettingsGui::scannerPaths() const
|
||||
{
|
||||
QString musicLocation;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
musicLocation = QStandardPaths::writableLocation( QStandardPaths::MusicLocation );
|
||||
#else
|
||||
musicLocation = QDesktopServices::storageLocation( QDesktopServices::MusicLocation );
|
||||
#endif
|
||||
|
||||
return value( "scanner/paths", musicLocation ).toStringList();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettingsGui::setAtticaResolverState( const QString& resolver, AtticaManager::ResolverState state )
|
||||
{
|
||||
AtticaManager::StateHash resolvers = value( "script/atticaresolverstates" ).value< AtticaManager::StateHash >();
|
||||
AtticaManager::Resolver r = resolvers.value( resolver );
|
||||
r.state = state;
|
||||
resolvers.insert( resolver, r );
|
||||
setValue( "script/atticaresolverstates", QVariant::fromValue< AtticaManager::StateHash >( resolvers ) );
|
||||
|
||||
sync();
|
||||
}
|
||||
|
||||
|
||||
AtticaManager::StateHash
|
||||
TomahawkSettingsGui::atticaResolverStates() const
|
||||
{
|
||||
return value( "script/atticaresolverstates" ).value< AtticaManager::StateHash >();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettingsGui::setAtticaResolverStates( const AtticaManager::StateHash states )
|
||||
{
|
||||
setValue( "script/atticaresolverstates", QVariant::fromValue< AtticaManager::StateHash >( states ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettingsGui::removeAtticaResolverState ( const QString& resolver )
|
||||
{
|
||||
AtticaManager::StateHash resolvers = value( "script/atticaresolverstates" ).value< AtticaManager::StateHash >();
|
||||
resolvers.remove( resolver );
|
||||
setValue( "script/atticaresolverstates", QVariant::fromValue< AtticaManager::StateHash >( resolvers ) );
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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_SETTINGS_GUI_H
|
||||
#define TOMAHAWK_SETTINGS_GUI_H
|
||||
|
||||
#include "TomahawkSettings.h"
|
||||
#include "AtticaManager.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
#include "DllMacro.h"
|
||||
|
||||
/**
|
||||
* Convenience wrapper around QSettings for tomahawk-specific config
|
||||
*/
|
||||
class DLLEXPORT TomahawkSettingsGui : public TomahawkSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static TomahawkSettingsGui* instanceGui();
|
||||
|
||||
explicit TomahawkSettingsGui( QObject* parent = 0 );
|
||||
virtual ~TomahawkSettingsGui();
|
||||
|
||||
virtual QString storageCacheLocation() const;
|
||||
virtual QStringList scannerPaths() const;
|
||||
|
||||
AtticaManager::StateHash atticaResolverStates() const;
|
||||
void setAtticaResolverStates( const AtticaManager::StateHash states );
|
||||
|
||||
void setAtticaResolverState( const QString& resolver, AtticaManager::ResolverState state );
|
||||
void removeAtticaResolverState( const QString& resolver );
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -19,7 +19,7 @@
|
||||
#include "BinaryInstallerHelper.h"
|
||||
|
||||
#include "accounts/AccountManager.h"
|
||||
#include "TomahawkSettingsGui.h"
|
||||
#include "TomahawkSettings.h"
|
||||
#include <QTemporaryFile>
|
||||
|
||||
BinaryInstallerHelper::BinaryInstallerHelper( QTemporaryFile* tempFile, const QString& resolverId, bool createAccount, AtticaManager* manager )
|
||||
@ -64,7 +64,7 @@ BinaryInstallerHelper::installSucceeded( const QString& path )
|
||||
m_manager.data()->m_resolverStates[ m_resolverId ].scriptPath = path;
|
||||
m_manager.data()->m_resolverStates[ m_resolverId ].state = AtticaManager::Installed;
|
||||
|
||||
TomahawkSettingsGui::instanceGui()->setAtticaResolverStates( m_manager.data()->m_resolverStates );
|
||||
TomahawkSettings::instance()->setAtticaResolverStates( m_manager.data()->m_resolverStates );
|
||||
emit m_manager.data()->resolverInstalled( m_resolverId );
|
||||
emit m_manager.data()->resolverStateChanged( m_resolverId );
|
||||
|
||||
|
@ -71,17 +71,15 @@
|
||||
#include "utils/TomahawkCache.h"
|
||||
#include "widgets/SplashWidget.h"
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include "resolvers/JSResolver.h"
|
||||
#include "resolvers/ScriptResolver.h"
|
||||
#include "utils/SpotifyParser.h"
|
||||
#include "AtticaManager.h"
|
||||
#include "TomahawkWindow.h"
|
||||
#include "dialogs/SettingsDialog.h"
|
||||
#include "ActionCollection.h"
|
||||
#include "widgets/HeaderLabel.h"
|
||||
#include "TomahawkSettingsGui.h"
|
||||
#endif
|
||||
#include "resolvers/JSResolver.h"
|
||||
#include "resolvers/ScriptResolver.h"
|
||||
#include "utils/SpotifyParser.h"
|
||||
#include "AtticaManager.h"
|
||||
#include "TomahawkWindow.h"
|
||||
#include "dialogs/SettingsDialog.h"
|
||||
#include "ActionCollection.h"
|
||||
#include "widgets/HeaderLabel.h"
|
||||
#include "TomahawkSettings.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
static pascal OSErr appleEventHandler( const AppleEvent*, AppleEvent*, long );
|
||||
#endif
|
||||
|
||||
#include "TomahawkSettingsGui.h"
|
||||
#include "TomahawkSettings.h"
|
||||
#ifdef WITH_CRASHREPORTER
|
||||
#include "libcrashreporter-handler/Handler.h"
|
||||
#endif
|
||||
@ -156,13 +156,7 @@ main( int argc, char *argv[] )
|
||||
|
||||
// MUST register StateHash ****before*** initing TomahawkSettingsGui as constructor of settings does upgrade before Gui subclass registers type
|
||||
TomahawkSettings::registerCustomSettingsHandlers();
|
||||
TomahawkSettingsGui::registerCustomSettingsHandlers();
|
||||
|
||||
#ifdef ENABLE_HEADLESS
|
||||
new TomahawkSettings( &a );
|
||||
#else
|
||||
new TomahawkSettingsGui( &a );
|
||||
#endif
|
||||
|
||||
#ifdef WITH_CRASHREPORTER
|
||||
new CrashReporter::Handler( QDir::tempPath(), TomahawkSettings::instance()->crashReporterEnabled() && !TomahawkUtils::headless(), "tomahawk_crash_reporter" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user