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

* Fixed TWK-261 - Make "show offline sources" a checkable option, and save its value in settings.

This commit is contained in:
Alejandro Wainzinger 2011-07-21 01:57:41 -07:00
parent dbf31d704a
commit bcf7d9d689
9 changed files with 39 additions and 30 deletions

View File

@ -447,6 +447,17 @@ TomahawkSettings::setVerboseNotifications( bool notifications )
setValue( "ui/notifications/verbose", notifications );
}
bool
TomahawkSettings::showOfflineSources() const
{
return value( "collection/sources/showoffline", false ).toBool();
}
void
TomahawkSettings::setShowOfflineSources( bool show )
{
setValue( "collection/sources/showoffline", show );
}
QByteArray
TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const

View File

@ -71,6 +71,10 @@ public:
bool verboseNotifications() const;
void setVerboseNotifications( bool notifications );
// Collection Stuff
bool showOfflineSources() const;
void setShowOfflineSources( bool show );
/// Playlist stuff
QByteArray playlistColumnSizes( const QString& playlistid ) const;
void setPlaylistColumnSizes( const QString& playlistid, const QByteArray& state );

View File

@ -44,21 +44,12 @@ SourcesProxyModel::SourcesProxyModel( SourcesModel* model, QObject* parent )
void
SourcesProxyModel::showOfflineSources()
SourcesProxyModel::showOfflineSources( bool offlineSourcesShown )
{
m_filtered = false;
m_filtered = !offlineSourcesShown;
invalidateFilter();
}
void
SourcesProxyModel::hideOfflineSources()
{
m_filtered = true;
invalidateFilter();
}
bool
SourcesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
{

View File

@ -31,8 +31,7 @@ public:
explicit SourcesProxyModel( SourcesModel* model, QObject* parent = 0 );
public slots:
void showOfflineSources();
void hideOfflineSources();
void showOfflineSources( bool offlineSourcesShown );
void selectRequested( const QModelIndex& );

View File

@ -26,6 +26,7 @@
#include "sourcetree/items/collectionitem.h"
#include "audio/audioengine.h"
#include "sourceplaylistinterface.h"
#include "tomahawksettings.h"
#include <QAction>
#include <QApplication>
@ -110,7 +111,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
connect( this, SIGNAL( expanded( QModelIndex ) ), this, SLOT( onItemExpanded( QModelIndex ) ) );
// connect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), SLOT( onSelectionChanged() ) );
hideOfflineSources();
showOfflineSources( TomahawkSettings::instance()->showOfflineSources() );
// Light-blue sourcetree on osx
#ifdef Q_WS_MAC
@ -199,19 +200,11 @@ SourceTreeView::setupMenus()
void
SourceTreeView::showOfflineSources()
SourceTreeView::showOfflineSources( bool offlineSourcesShown )
{
m_proxyModel->showOfflineSources();
m_proxyModel->showOfflineSources( offlineSourcesShown );
}
void
SourceTreeView::hideOfflineSources()
{
m_proxyModel->hideOfflineSources();
}
void
SourceTreeView::onItemActivated( const QModelIndex& index )
{

View File

@ -38,8 +38,7 @@ public:
explicit SourceTreeView( QWidget* parent = 0 );
public slots:
void showOfflineSources();
void hideOfflineSources();
void showOfflineSources( bool offlineSourcesShown );
void renamePlaylist();
signals:

View File

@ -206,6 +206,9 @@ TomahawkWindow::setupSideBar()
ui->splitter->setStretchFactor( 1, 3 );
ui->splitter->setCollapsible( 1, false );
ui->splitter->setHandleWidth( 1 );
ui->actionShowOfflineSources->setChecked( TomahawkSettings::instance()->showOfflineSources() );
}
@ -298,8 +301,7 @@ TomahawkWindow::setupSignals()
connect( ui->actionCreate_New_Station, SIGNAL( triggered() ), SLOT( createStation() ));
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
connect( ui->actionExit, SIGNAL( triggered() ), qApp, SLOT( quit() ) );
connect( ui->actionHideOfflineSources, SIGNAL( triggered() ), m_sourcetree, SLOT( hideOfflineSources() ) );
connect( ui->actionShowOfflineSources, SIGNAL( triggered() ), m_sourcetree, SLOT( showOfflineSources() ) );
connect( ui->actionShowOfflineSources, SIGNAL( triggered() ), SLOT( showOfflineSources() ) );
connect( ui->actionPlay, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( playPause() ) );
connect( ui->actionNext, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( previous() ) );
@ -474,6 +476,13 @@ TomahawkWindow::pluginMenuRemoved( QMenu* menu )
}
}
void
TomahawkWindow::showOfflineSources()
{
m_sourcetree->showOfflineSources( ui->actionShowOfflineSources->isChecked() );
TomahawkSettings::instance()->setShowOfflineSources( ui->actionShowOfflineSources->isChecked() );
}
void
TomahawkWindow::loadSpiff()

View File

@ -71,6 +71,7 @@ public slots:
void rescanCollectionManually();
void pluginMenuAdded(QMenu*);
void pluginMenuRemoved(QMenu*);
void showOfflineSources();
private slots:
void onSipConnected();

View File

@ -35,7 +35,7 @@
<x>0</x>
<y>0</y>
<width>1000</width>
<height>20</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuSettings">
@ -56,7 +56,6 @@
<addaction name="actionRescanCollection"/>
<addaction name="separator"/>
<addaction name="actionShowOfflineSources"/>
<addaction name="actionHideOfflineSources"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
@ -164,6 +163,9 @@
</property>
</action>
<action name="actionShowOfflineSources">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Show Offline Sources</string>
</property>