1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-30 17:20:26 +02:00

* Use native file-dialogs to pick library paths.

This commit is contained in:
Christian Muehlhaeuser
2013-09-06 15:02:53 +02:00
parent 4bc5b8cc98
commit 7d16b5181d
3 changed files with 98 additions and 22 deletions

View File

@@ -191,10 +191,18 @@ SettingsDialog::SettingsDialog(QObject *parent )
m_collectionWidgetUi->scannerTimeSpinBox->hide();
}
foreach ( const QString& dir, TomahawkSettings::instance()->scannerPaths() )
/* foreach ( const QString& dir, TomahawkSettings::instance()->scannerPaths() )
{
m_collectionWidgetUi->dirTree->checkPath( dir, Qt::Checked );
}
}*/
m_collectionWidgetUi->pathListWidget->addItems( TomahawkSettings::instance()->scannerPaths() );
const int buttonSize = TomahawkUtils::defaultFontHeight() * 2.5;
m_collectionWidgetUi->addLibraryPathButton->setFixedSize( buttonSize, buttonSize );
m_collectionWidgetUi->removeLibraryPathButton->setFixedSize( m_collectionWidgetUi->addLibraryPathButton->size() );
connect( m_collectionWidgetUi->addLibraryPathButton, SIGNAL( clicked() ), SLOT( addLibraryPath() ) );
connect( m_collectionWidgetUi->removeLibraryPathButton, SIGNAL( clicked() ), SLOT( removeLibraryPath() ) );
int buttonsWidth = qMax( m_advancedWidgetUi->proxyButton->sizeHint().width(),
m_advancedWidgetUi->aclEntryClearButton->sizeHint().width() );
@@ -213,7 +221,7 @@ SettingsDialog::SettingsDialog(QObject *parent )
m_collectionWidget->setContentsMargins( 6, 6, 6, 6 );
m_collectionWidget->setMinimumHeight( m_collectionWidgetUi->verticalLayout->sizeHint().height() + 20 );
m_collectionWidgetUi->dirTree->setAttribute( Qt::WA_MacShowFocusRect, false );
m_collectionWidgetUi->pathListWidget->setAttribute( Qt::WA_MacShowFocusRect, false );
m_advancedWidget->setContentsMargins( 6, 6, 6, 6 );
m_advancedWidget->setMinimumHeight( m_advancedWidgetUi->verticalLayout->sizeHint().height() );
@@ -274,7 +282,13 @@ SettingsDialog::saveSettings()
s->setExternalHostname( m_advancedWidgetUi->staticHostName->text() );
s->setExternalPort( m_advancedWidgetUi->staticPort->value() );
s->setScannerPaths( m_collectionWidgetUi->dirTree->getCheckedPaths() );
QStringList libraryPaths;
for ( int i = 0; i < m_collectionWidgetUi->pathListWidget->count(); i++ )
{
libraryPaths << m_collectionWidgetUi->pathListWidget->item( i )->text();
}
s->setScannerPaths( libraryPaths );
// s->setScannerPaths( m_collectionWidgetUi->dirTree->getCheckedPaths() );
s->setWatchForChanges( m_collectionWidgetUi->checkBoxWatchForChanges->isChecked() );
s->setScannerTime( m_collectionWidgetUi->scannerTimeSpinBox->value() );
s->setEnableEchonestCatalogs( m_collectionWidgetUi->enableEchonestCatalog->isChecked() );
@@ -287,7 +301,7 @@ SettingsDialog::saveSettings()
if ( m_restartRequired )
QMessageBox::information( 0, tr( "Information" ), tr( "Some changed settings will not take effect until Tomahawk is restarted" ) );
m_collectionWidgetUi->dirTree->cleanup();
// m_collectionWidgetUi->dirTree->cleanup();
Tomahawk::Utils::NetworkProxyFactory* proxyFactory = Tomahawk::Utils::proxyFactory();
if ( !m_advancedWidgetUi->enableProxyCheckBox->isChecked() )
@@ -398,6 +412,30 @@ SettingsDialog::toggleAutoDetectIp( bool checked )
}
void
SettingsDialog::addLibraryPath()
{
QString dir = QFileDialog::getExistingDirectory( m_collectionWidget, tr( "Open Directory" ),
QDir::homePath(),
QFileDialog::ShowDirsOnly );
if ( !dir.isEmpty() )
{
m_collectionWidgetUi->pathListWidget->addItem( dir );
}
}
void
SettingsDialog::removeLibraryPath()
{
if ( m_collectionWidgetUi->pathListWidget->currentRow() >= 0 )
{
m_collectionWidgetUi->pathListWidget->takeItem( m_collectionWidgetUi->pathListWidget->currentRow() );
}
}
void
SettingsDialog::updateScanOptionsView()
{

View File

@@ -89,6 +89,8 @@ private slots:
void toggleProxyEnabled();
void toggleAutoDetectIp( bool checked );
void showProxySettings();
void addLibraryPath();
void removeLibraryPath();
void accountsFilterChanged( int );

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>403</width>
<height>370</height>
<width>423</width>
<height>367</height>
</rect>
</property>
<property name="sizePolicy">
@@ -19,21 +19,64 @@
<property name="windowTitle">
<string notr="true" extracomment="not translatable because not shown to the user">Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>2</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Path to scan for music files:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Path to scan for music files:</string>
</property>
</widget>
<widget class="QListWidget" name="pathListWidget"/>
</item>
<item>
<widget class="CheckDirTree" name="dirTree"/>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>4</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="addLibraryPathButton">
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="removeLibraryPathButton">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
@@ -90,13 +133,6 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>CheckDirTree</class>
<extends>QTreeView</extends>
<header location="global">widgets/CheckDirTree.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>