1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-01 18:04:05 +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(); 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->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(), int buttonsWidth = qMax( m_advancedWidgetUi->proxyButton->sizeHint().width(),
m_advancedWidgetUi->aclEntryClearButton->sizeHint().width() ); m_advancedWidgetUi->aclEntryClearButton->sizeHint().width() );
@@ -213,7 +221,7 @@ SettingsDialog::SettingsDialog(QObject *parent )
m_collectionWidget->setContentsMargins( 6, 6, 6, 6 ); m_collectionWidget->setContentsMargins( 6, 6, 6, 6 );
m_collectionWidget->setMinimumHeight( m_collectionWidgetUi->verticalLayout->sizeHint().height() + 20 ); 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->setContentsMargins( 6, 6, 6, 6 );
m_advancedWidget->setMinimumHeight( m_advancedWidgetUi->verticalLayout->sizeHint().height() ); m_advancedWidget->setMinimumHeight( m_advancedWidgetUi->verticalLayout->sizeHint().height() );
@@ -274,7 +282,13 @@ SettingsDialog::saveSettings()
s->setExternalHostname( m_advancedWidgetUi->staticHostName->text() ); s->setExternalHostname( m_advancedWidgetUi->staticHostName->text() );
s->setExternalPort( m_advancedWidgetUi->staticPort->value() ); 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->setWatchForChanges( m_collectionWidgetUi->checkBoxWatchForChanges->isChecked() );
s->setScannerTime( m_collectionWidgetUi->scannerTimeSpinBox->value() ); s->setScannerTime( m_collectionWidgetUi->scannerTimeSpinBox->value() );
s->setEnableEchonestCatalogs( m_collectionWidgetUi->enableEchonestCatalog->isChecked() ); s->setEnableEchonestCatalogs( m_collectionWidgetUi->enableEchonestCatalog->isChecked() );
@@ -287,7 +301,7 @@ SettingsDialog::saveSettings()
if ( m_restartRequired ) if ( m_restartRequired )
QMessageBox::information( 0, tr( "Information" ), tr( "Some changed settings will not take effect until Tomahawk is restarted" ) ); 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(); Tomahawk::Utils::NetworkProxyFactory* proxyFactory = Tomahawk::Utils::proxyFactory();
if ( !m_advancedWidgetUi->enableProxyCheckBox->isChecked() ) 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 void
SettingsDialog::updateScanOptionsView() SettingsDialog::updateScanOptionsView()
{ {

View File

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

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>403</width> <width>423</width>
<height>370</height> <height>367</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@@ -19,12 +19,10 @@
<property name="windowTitle"> <property name="windowTitle">
<string notr="true" extracomment="not translatable because not shown to the user">Form</string> <string notr="true" extracomment="not translatable because not shown to the user">Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin"> <property name="margin">
<number>2</number> <number>2</number>
</property> </property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
@@ -33,7 +31,52 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="CheckDirTree" name="dirTree"/> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QListWidget" name="pathListWidget"/>
</item>
<item>
<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> </item>
</layout> </layout>
</item> </item>
@@ -90,13 +133,6 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>CheckDirTree</class>
<extends>QTreeView</extends>
<header location="global">widgets/CheckDirTree.h</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>