#include "options.h" #include "optionssimple.h" #include "optionsdetailed.h" #include "config.h" #include #include #include #include #include #include #include #include #include #include // FIXME prevent converting wav files to wav Options::Options( Config* _config, const TQString &text, TQWidget *tqparent, const char *name ) : TQWidget( tqparent, name ) { config = _config; connect( config, TQT_SIGNAL(configChanged()), this, TQT_SLOT(configChanged()) ); TQGridLayout *gridLayout = new TQGridLayout( this, 1, 1 ); tab = new KTabWidget( this, "tab" ); optionsDetailed = new OptionsDetailed( config, this, "optionsDetailed" ); optionsSimple = new OptionsSimple( config, optionsDetailed, text, this, "optionsSimple" ); tab->addTab( optionsSimple, i18n("Simple") ); connect( optionsSimple, TQT_SIGNAL(optionsChanged()), this, TQT_SLOT(somethingChanged()) ); tab->addTab( optionsDetailed, i18n("Detailed") ); connect( optionsDetailed, TQT_SIGNAL(optionsChanged()), this, TQT_SLOT(somethingChanged()) ); // connect( optionsSimple, TQT_SIGNAL(setFormat(const TQString&)), // optionsDetailed, TQT_SLOT(setFormat(const TQString&)) // ); // connect( optionsSimple, TQT_SIGNAL(setQualityMode(const TQString&)), // optionsDetailed, TQT_SLOT(setQualityMode(const TQString&)) // ); // connect( optionsSimple, TQT_SIGNAL(setQuality(int)), // optionsDetailed, TQT_SLOT(setQuality(int)) // ); // connect( optionsSimple, TQT_SIGNAL(setBitrateMode(const TQString&)), // optionsDetailed, TQT_SLOT(setBitrateMode(const TQString&)) // ); // connect( optionsSimple, TQT_SIGNAL(setBitrateRangeEnabled(bool)), // optionsDetailed, TQT_SLOT(setBitrateRangeEnabled(bool)) // ); // connect( optionsSimple, TQT_SIGNAL(setMinBitrate(int)), // optionsDetailed, TQT_SLOT(setMinBitrate(int)) // ); // connect( optionsSimple, TQT_SIGNAL(setMaxBitrate(int)), // optionsDetailed, TQT_SLOT(setMaxBitrate(int)) // ); // connect( optionsSimple, TQT_SIGNAL(setSamplingrateEnabled(bool)), // optionsDetailed, TQT_SLOT(setSamplingrateEnabled(bool)) // ); // connect( optionsSimple, TQT_SIGNAL(setSamplingrate(int)), // optionsDetailed, TQT_SLOT(setSamplingrate(int)) // ); // connect( optionsSimple, TQT_SIGNAL(setSamplingrate(const TQString&)), // optionsDetailed, TQT_SLOT(setSamplingrate(const TQString&)) // ); // connect( optionsSimple, TQT_SIGNAL(setChannelsEnabled(bool)), // optionsDetailed, TQT_SLOT(setChannelsEnabled(bool)) // ); // connect( optionsSimple, TQT_SIGNAL(setChannels(const TQString&)), // optionsDetailed, TQT_SLOT(setChannels(const TQString&)) // ); // connect( optionsSimple, TQT_SIGNAL(setReplayGainEnabled(bool)), // optionsDetailed, TQT_SLOT(setReplayGainEnabled(bool)) // ); // connect( optionsSimple, TQT_SIGNAL(setOutputDirectoryMode(OutputDirectory::Mode)), // optionsDetailed, TQT_SLOT(setOutputDirectoryMode(OutputDirectory::Mode)) // ); // connect( optionsSimple, TQT_SIGNAL(setOutputDirectoryPath(const TQString&)), // optionsDetailed, TQT_SLOT(setOutputDirectoryPath(const TQString&)) // ); // connect( optionsSimple, TQT_SIGNAL(setOptions(const ConversionOptions&)), // optionsDetailed, TQT_SLOT(setCurrentOptions(const ConversionOptions&)) // ); // connect( optionsSimple, TQT_SIGNAL(setUserOptions(const TQString&)), // optionsDetailed, TQT_SLOT(setUserOptions(const TQString&)) // ); if( config->data.general.startTab == 0 ) tab->setCurrentPage( config->data.general.lastTab ); else tab->setCurrentPage( config->data.general.startTab - 1 ); gridLayout->addWidget( tab, 0, 0 ); connect( tab, TQT_SIGNAL( currentChanged(TQWidget*) ), this, TQT_SLOT( tabChanged(TQWidget*) ) ); // draw the toggle button TQVBoxLayout *optionsTopBox = new TQVBoxLayout( -1, "optionsTopBox" ); gridLayout->addLayout( optionsTopBox, 0, 0 ); TQHBoxLayout *optionsBox = new TQHBoxLayout( 6, "optionsBox" ); optionsTopBox->addLayout( optionsBox ); optionsTopBox->addStretch(); optionsBox->addStretch(); // pPluginsNotify = new KPushButton( "", this, "pPluginsNotify"); // pPluginsNotify->setPixmap( KGlobal::iconLoader()->loadIcon("connect_creating",KIcon::Toolbar) ); // TQToolTip::add( pPluginsNotify, i18n("There are new plugin updates available.\nClick on this button in order to open the configuration dialog.") ); // pPluginsNotify->hide(); // pPluginsNotify->setPaletteBackgroundColor( TQColor(255,220,247) ); // optionsBox->addWidget( pPluginsNotify ); // connect( pPluginsNotify, TQT_SIGNAL(clicked()), // this, TQT_SLOT(showConfigDialogPlugins()) // ); pBackendsNotify = new KPushButton( "", this, "pBackendsNotify"); pBackendsNotify->setPixmap( KGlobal::iconLoader()->loadIcon("kcmsystem",KIcon::Toolbar) ); TQToolTip::add( pBackendsNotify, i18n("soundKonverter either found new backends or misses some.\nClick on this button in order to open the configuration dialog.") ); pBackendsNotify->setShown( config->backendsChanged ); config->backendsChanged = false; pBackendsNotify->setPaletteBackgroundColor( TQColor(255,220,247) ); optionsBox->addWidget( pBackendsNotify ); connect( pBackendsNotify, TQT_SIGNAL(clicked()), this, TQT_SLOT(showConfigDialogBackends()) ); pAdvancedOptionsToggle = new KPushButton( i18n("Advanced Options"), this, "pAdvancedOptionsToggle"); pAdvancedOptionsToggle->setToggleButton( true ); pAdvancedOptionsToggle->hide(); optionsBox->addWidget( pAdvancedOptionsToggle ); connect( pAdvancedOptionsToggle, TQT_SIGNAL(clicked()), optionsDetailed, TQT_SLOT(toggleAdvancedOptions()) ); /* NOTE kaligames.de is down if( config->data.plugins.checkForUpdates ) { config->onlinePluginsChanged = false; getPluginListJob = KIO::file_copy("http://kaligames.de/downloads/soundkonverter/plugins/download.php?version=" + TQString::number(config->data.app.configVersion), locateLocal("data","soundkonverter/pluginlist_new.txt"), -1, true, false, false ); connect( getPluginListJob, TQT_SIGNAL(result(KIO::Job*)), this, TQT_SLOT(getPluginListFinished(KIO::Job*)) ); } */ if( config->data.general.defaultProfile == i18n("Last used") || config->getAllProfiles().findIndex(config->data.general.defaultProfile) != -1 ) { setCurrentOptions( config->getProfile(config->data.general.defaultProfile) ); } else { setProfile( config->data.general.defaultProfile ); setFormat( config->data.general.defaultFormat ); } } Options::~Options() {} // void Options::getPluginListFinished( KIO::Job* job ) // { // if( job->error() == 0 ) { // TQFile file( locateLocal("data","soundkonverter/pluginlist.txt") ); // TQFile newFile( locateLocal("data","soundkonverter/pluginlist_new.txt") ); // // if( !file.exists() ) { // TODO check against the installed plugins // pPluginsNotify->show(); // KIO::file_move( locateLocal("data","soundkonverter/pluginlist_new.txt"), locateLocal("data","soundkonverter/pluginlist.txt"), -1, true, false, false ); // config->onlinePluginsChanged = true; // return; // } // // if( file.open(IO_ReadOnly) && newFile.open(IO_ReadOnly) ) { // TQTextStream stream( &file ); // TQTextStream newStream( &newFile ); // while( !stream.atEnd() && !newStream.atEnd() ) { // if( stream.readLine() != newStream.readLine() ) { // file.close(); // newFile.close(); // pPluginsNotify->show(); // KIO::file_move( locateLocal("data","soundkonverter/pluginlist_new.txt"), locateLocal("data","soundkonverter/pluginlist.txt"), -1, true, false, false ); // config->onlinePluginsChanged = true; // return; // } // } // if( stream.atEnd() != newStream.atEnd() ) { // file.close(); // newFile.close(); // pPluginsNotify->show(); // KIO::file_move( locateLocal("data","soundkonverter/pluginlist_new.txt"), locateLocal("data","soundkonverter/pluginlist.txt"), -1, true, false, false ); // config->onlinePluginsChanged = true; // return; // } // file.close(); // newFile.close(); // } // newFile.remove(); // } // } // void Options::showConfigDialogPlugins() // { // pPluginsNotify->hide(); // emit showConfigPluginsPage(); // } void Options::showConfigDialogBackends() { pBackendsNotify->hide(); emit showConfigEnvironmentPage(); } ConversionOptions Options::getCurrentOptions() { return optionsDetailed->getCurrentOptions(); } void Options::setCurrentOptions( const ConversionOptions& options ) { optionsDetailed->setCurrentOptions( options ); /*if( tab->page(tab->currentPageIndex()) == optionsSimple ) { optionsSimple->refill(); }*/ optionsSimple->refill(); } void Options::tabChanged( TQWidget* widget ) { if( widget == optionsSimple ) { pAdvancedOptionsToggle->hide(); optionsSimple->refill(); } else { pAdvancedOptionsToggle->show(); } config->data.general.lastTab = tab->currentPageIndex(); } void Options::setProfile( const TQString& profile ) { optionsSimple->setCurrentProfile( profile ); } void Options::setFormat( const TQString& format ) { optionsSimple->setCurrentFormat( format ); } void Options::setOutputDirectory( const TQString& directory ) { optionsSimple->setCurrentOutputDirectory( directory ); } void Options::somethingChanged() { emit optionsChanged(); } // TODO right this way? - seems to work void Options::configChanged() { optionsDetailed->refill(); /*if( tab->page(tab->currentPageIndex()) == optionsSimple ) { optionsSimple->refill(); }*/ optionsSimple->refill(); }