/src/LoadXSPFDialog.cpp

http://github.com/tomahawk-player/tomahawk · C++ · 68 lines · 40 code · 11 blank · 17 comment · 1 complexity · 3a58d6aa1b3afefb6236fca91f033b25 MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
  4. *
  5. * Tomahawk is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * Tomahawk is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "LoadXSPFDialog.h"
  19. #include "ui_LoadXSPFDialog.h"
  20. #include "TomahawkSettings.h"
  21. #include "Source.h"
  22. #include <QFileDialog>
  23. LoadXSPFDialog::LoadXSPFDialog( QWidget* parent, Qt::WindowFlags f )
  24. : QDialog( parent, f )
  25. , m_ui( new Ui_LoadXSPF )
  26. {
  27. m_ui->setupUi( this );
  28. #ifdef Q_WS_MAC
  29. m_ui->horizontalLayout->setContentsMargins( 0, 0, 0, 0 );
  30. m_ui->horizontalLayout->setSpacing( 5 );
  31. m_ui->verticalLayout->setContentsMargins( 0, 10, 0, 0 );
  32. m_ui->verticalLayout->setSpacing( 0 );
  33. #endif
  34. connect( m_ui->navigateButton, SIGNAL( clicked( bool ) ), this, SLOT( getLocalFile() ) );
  35. }
  36. LoadXSPFDialog::~LoadXSPFDialog()
  37. {
  38. }
  39. void
  40. LoadXSPFDialog::getLocalFile()
  41. {
  42. const QString path = TomahawkSettings::instance()->importXspfPath();
  43. QString url = QFileDialog::getOpenFileName( this, tr( "Load XSPF File" ), path, tr( "XSPF Files (*.xspf)" ) );
  44. if ( !url.isEmpty() )
  45. TomahawkSettings::instance()->setImportXspfPath( QFileInfo( url ).absoluteDir().absolutePath() );
  46. m_ui->lineEdit->setText( url );
  47. }
  48. QString
  49. LoadXSPFDialog::xspfUrl() const
  50. {
  51. return m_ui->lineEdit->text();
  52. }
  53. bool
  54. LoadXSPFDialog::autoUpdate() const
  55. {
  56. return m_ui->autoUpdate->isChecked();
  57. }