Пример #1
0
void
SettingsDialog::saveSettings()
{
    qDebug() << Q_FUNC_INFO;

    TomahawkSettings* s = TomahawkSettings::instance();

    s->setCrashReporterEnabled( m_advancedWidgetUi->checkBoxReporter->checkState() == Qt::Checked );
    s->setHttpEnabled( m_advancedWidgetUi->checkBoxHttp->checkState() == Qt::Checked );
    s->setHttpBindAll( m_advancedWidgetUi->checkBoxListenApi->checkState() == Qt::Checked );
    s->setSongChangeNotificationEnabled( m_advancedWidgetUi->checkBoxSongChangeNotifications->checkState() == Qt::Checked );
    s->setProxyType( m_advancedWidgetUi->enableProxyCheckBox->isChecked() ? QNetworkProxy::Socks5Proxy : QNetworkProxy::NoProxy );
    s->setExternalAddressMode( m_advancedWidgetUi->upnpRadioButton->isChecked() ? Tomahawk::Network::ExternalAddress::Upnp : ( m_advancedWidgetUi->lanOnlyRadioButton->isChecked() ? Tomahawk::Network::ExternalAddress::Lan : Tomahawk::Network::ExternalAddress::Static ) );

    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() );
    s->setDownloadsPath( m_downloadsWidgetUi->downloadsFolder->text() );
    s->setDownloadsPreferredFormat( m_downloadsFormats.key( m_downloadsWidgetUi->preferredFormatComboBox->currentText() ) );

//         s->setNowPlayingEnabled( ui->checkBoxEnableAdium->isChecked() );

    s->applyChanges();
    s->sync();

    if ( m_restartRequired )
        QMessageBox::information( 0, tr( "Information" ), tr( "Some changed settings will not take effect until Tomahawk is restarted" ) );

//    m_collectionWidgetUi->dirTree->cleanup();

    Tomahawk::Utils::NetworkProxyFactory* proxyFactory = Tomahawk::Utils::proxyFactory();
    if ( !m_advancedWidgetUi->enableProxyCheckBox->isChecked() )
    {
        tDebug() << Q_FUNC_INFO << "Got NoProxy selected";
        proxyFactory->setProxy( QNetworkProxy::NoProxy, s->proxyDns() );
    }
    else
    {
        tDebug() << Q_FUNC_INFO << "Got Socks5Proxy selected";
        proxyFactory->setProxy( QNetworkProxy( QNetworkProxy::Socks5Proxy, s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() ), s->proxyDns() );
        if ( !s->proxyNoProxyHosts().isEmpty() )
        {
            tDebug() << Q_FUNC_INFO << "noproxy hosts:" << s->proxyNoProxyHosts();
            tDebug() << Q_FUNC_INFO << "split noproxy line edit is " << s->proxyNoProxyHosts().split( ' ', QString::SkipEmptyParts );
            proxyFactory->setNoProxyHosts( s->proxyNoProxyHosts().split( ' ', QString::SkipEmptyParts ) );
        }
    }

    emit finished( true );
}
Пример #2
0
ProxyDialog::ProxyDialog( QWidget *parent )
    : QDialog( parent )
    , ui( new Ui::ProxyDialog )
{
    ui->setupUi( this );

    // ugly, I know, but...
    TomahawkSettings* s = TomahawkSettings::instance();

    ui->hostLineEdit->setText( s->proxyHost() );
    ui->portSpinBox->setValue( s->proxyPort() );
    ui->userLineEdit->setText( s->proxyUsername() );
    ui->passwordLineEdit->setText( s->proxyPassword() );
    ui->checkBoxUseProxyForDns->setChecked( s->proxyDns() );
    ui->noHostLineEdit->setText( s->proxyNoProxyHosts() );
}
Пример #3
0
void
TomahawkApp::init()
{
    qDebug() << "TomahawkApp thread:" << thread();
    m_logFile.setFileName( TomahawkUtils::logFilePath() );
    Logger::setupLogfile( m_logFile );

    qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) );

    tLog() << "Starting Tomahawk...";

    m_headless = true;
    m_headless = arguments().contains( "--headless" );
    setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) );

#ifndef Q_OS_MAC
    setQuitOnLastWindowClosed( false );
#endif

    if ( arguments().contains( "--splash" ) )
    {
        startSplashWidget( "Splash screen test\n" );
        updateSplashWidgetMessage( "Splash screen test\n2/7" );
    }

    TomahawkStyle::loadFonts();
    QFont f = font();
    TomahawkUtils::setSystemFont( f );
    f.setFamily( "Roboto" );
#ifdef Q_OS_WIN
    f.setPointSize( 10 );
#endif
#ifdef Q_OS_MAC
    f.setPointSize( f.pointSize() - 2 );
#endif

    setFont( f );
    tDebug() << "Default font:" << f.pixelSize() << f.pointSizeF() << f.family() << QFontMetrics( f ).height();
    TomahawkUtils::setDefaultFontSize( f.pointSize() );

    TomahawkUtils::setHeadless( m_headless );
    new ACLRegistryImpl( this );

    TomahawkSettings *s = TomahawkSettings::instance();
    Tomahawk::Utils::setProxyDns( s->proxyDns() );
    Tomahawk::Utils::setProxyType( s->proxyType() );
    Tomahawk::Utils::setProxyHost( s->proxyHost() );
    Tomahawk::Utils::setProxyPort( s->proxyPort() );
    Tomahawk::Utils::setProxyUsername( s->proxyUsername() );
    Tomahawk::Utils::setProxyPassword( s->proxyPassword() );
    Tomahawk::Utils::setProxyNoProxyHosts( s->proxyNoProxyHosts() );

    // Cause the creation of the nam, but don't need to address it directly, so prevent warning
    tDebug() << "Setting NAM:" << Tomahawk::Utils::nam();

    DownloadManager::instance();
    m_audioEngine = QPointer<AudioEngine>( new AudioEngine );

    // init pipeline and resolver factories
    new Pipeline();

    m_servent = QPointer<Servent>( new Servent( this ) );
    connect( m_servent.data(), SIGNAL( ready() ), SLOT( initSIP() ) );

    tDebug() << "Init Database.";
    initDatabase();

    Pipeline::instance()->addExternalResolverFactory(
                std::bind( &JSResolver::factory, std::placeholders::_1,
                           std::placeholders::_2, std::placeholders::_3 ) );
    Pipeline::instance()->addExternalResolverFactory(
                std::bind( &ScriptResolver::factory, std::placeholders::_1,
                           std::placeholders::_2, std::placeholders::_3 ) );

    new ActionCollection( this );
    connect( ActionCollection::instance()->getAction( "quit" ), SIGNAL( triggered() ), SLOT( quit() ), Qt::UniqueConnection );

    QByteArray magic = QByteArray::fromBase64( enApiSecret );
    QByteArray wand = QByteArray::fromBase64( QCoreApplication::applicationName().toLatin1() );
    int length = magic.length(), n2 = wand.length();
    for ( int i = 0; i < length; i++ ) magic[i] = magic[i] ^ wand[i%n2];
    Echonest::Config::instance()->setAPIKey( magic );

    tDebug() << "Init Echonest Factory.";
    GeneratorFactory::registerFactory( "echonest", new EchonestFactory );
    tDebug() << "Init Database Factory.";
    GeneratorFactory::registerFactory( "database", new DatabaseFactory );

    // Register shortcut handler for this platform
#ifdef Q_OS_MAC
    m_shortcutHandler = QPointer<Tomahawk::ShortcutHandler>( new MacShortcutHandler( this ) );
    Tomahawk::setShortcutHandler( static_cast<MacShortcutHandler*>( m_shortcutHandler.data() ) );

    Tomahawk::setApplicationHandler( this );
    increaseMaxFileDescriptors();
#endif

#ifdef WITH_GNOMESHORTCUTHANDLER
    GnomeShortcutHandler *gnomeShortcutHandler = new GnomeShortcutHandler( this );
    gnomeShortcutHandler->DoRegister();
    m_shortcutHandler = QPointer<Tomahawk::ShortcutHandler>( gnomeShortcutHandler );
#endif

    // Connect up shortcuts
    if ( !m_shortcutHandler.isNull() )
    {
        connect( m_shortcutHandler.data(), SIGNAL( playPause() ), m_audioEngine.data(), SLOT( playPause() ) );
        connect( m_shortcutHandler.data(), SIGNAL( pause() ), m_audioEngine.data(), SLOT( pause() ) );
        connect( m_shortcutHandler.data(), SIGNAL( stop() ), m_audioEngine.data(), SLOT( stop() ) );
        connect( m_shortcutHandler.data(), SIGNAL( previous() ), m_audioEngine.data(), SLOT( previous() ) );
        connect( m_shortcutHandler.data(), SIGNAL( next() ), m_audioEngine.data(), SLOT( next() ) );
        connect( m_shortcutHandler.data(), SIGNAL( volumeUp() ), m_audioEngine.data(), SLOT( raiseVolume() ) );
        connect( m_shortcutHandler.data(), SIGNAL( volumeDown() ), m_audioEngine.data(), SLOT( lowerVolume() ) );
        connect( m_shortcutHandler.data(), SIGNAL( mute() ), m_audioEngine.data(), SLOT( mute() ) );
    }

    connect( Playlist::removalHandler().data(), SIGNAL( aboutToBeDeletePlaylist( Tomahawk::playlist_ptr ) ),
             SLOT( playlistRemoved( Tomahawk::playlist_ptr ) ));

    tDebug() << "Init InfoSystem.";
    m_infoSystem = QPointer<Tomahawk::InfoSystem::InfoSystem>( Tomahawk::InfoSystem::InfoSystem::instance() );
    connect( m_infoSystem, SIGNAL( ready() ), SLOT( onInfoSystemReady() ) );
}