Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/dlgprefshoutcast.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           dlgprefshoutcast.cpp  -  description
00003                              -------------------
00004     begin                : Thu Jun 19 2007
00005     copyright            : (C) 2008 by Wesley Stessens
00006                            (C) 2008 by Albert Santoni
00007                            (C) 2007 by John Sully
00008     email                :
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *   This program is free software; you can redistribute it and/or modify  *
00014  *   it under the terms of the GNU General Public License as published by  *
00015  *   the Free Software Foundation; either version 2 of the License, or     *
00016  *   (at your option) any later version.                                   *
00017  *                                                                         *
00018  ***************************************************************************/
00019 
00020 #include "dlgprefshoutcast.h"
00021 #include "defs_urls.h"
00022 #include <QtDebug>
00023 #include <QtCore>
00024 #include <QtGui>
00025 
00026 DlgPrefShoutcast::DlgPrefShoutcast(QWidget *parent, ConfigObject<ConfigValue> *_config) : QWidget(parent), Ui::DlgPrefShoutcastDlg()
00027 {
00028     m_pConfig = _config;
00029     int tmp_index = 0;  //Used for finding the index of an element by name in a combobox.
00030     QString tmp_string;
00031     setupUi(this);
00032 
00033     m_pUpdateShoutcastFromPrefs = new ControlObjectThreadMain(ControlObject::getControl(ConfigKey(SHOUTCAST_PREF_KEY, "update_from_prefs")));
00034 
00035     //Connections
00036     //connect(PushButtonBrowse, SIGNAL(clicked()),      this,   SLOT(slotBrowseSave()));
00037     //connect(LineEditRecPath,  SIGNAL(returnPressed()),  this, SLOT(slotApply()));
00038 
00039     /*
00040     connect(comboBoxEncoding, SIGNAL(activated(int)),   this,   SLOT(slotRecordPathChange()));
00041     connect(SliderQuality,    SIGNAL(valueChanged(int)), this,  SLOT(slotSliderQuality()));
00042     connect(SliderQuality,    SIGNAL(sliderMoved(int)), this,   SLOT(slotSliderQuality()));
00043     connect(SliderQuality,    SIGNAL(sliderReleased()), this,   SLOT(slotSliderQuality()));
00044     */
00045     //connect(CheckBoxRecord,    SIGNAL(stateChanged(int)), this, SLOT(slotApply()));
00046 
00047 
00048     //Enable live broadcasting checkbox
00049     enableLiveBroadcasting->setChecked((bool)m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"enabled")).toInt());
00050 
00051     //Server type combobox
00052     tmp_index = comboBoxServerType->findText(m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"servertype")));
00053     if (tmp_index < 0) //Set default if invalid.
00054         tmp_index = 0;
00055     comboBoxServerType->setCurrentIndex(tmp_index);
00056 
00057     //Mountpoint
00058     mountpoint->setText(m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"mountpoint")));
00059 
00060     //Host
00061     host->setText(m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"host")));
00062 
00063     //Port
00064     tmp_string = m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"port"));
00065     if (tmp_string.isEmpty())
00066         tmp_string = QString(SHOUTCAST_DEFAULT_PORT);
00067     port->setText(tmp_string);
00068 
00069     //Login
00070     login->setText(m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"login")));
00071 
00072     //Password
00073     password->setText(m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"password")));
00074 
00075     //Stream name
00076     stream_name->setText(m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"stream_name")));
00077 
00078     //Stream website
00079     tmp_string = m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"stream_website"));
00080     if (tmp_string.isEmpty())
00081         tmp_string = MIXXX_WEBSITE_URL;
00082     stream_website->setText(tmp_string);
00083 
00084     //Stream description
00085     stream_desc->setText(m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"stream_desc")));
00086 
00087     //Stream genre
00088     tmp_string = m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"stream_genre"));
00089     if (tmp_string.isEmpty())
00090         tmp_string = "Live Mix";
00091     stream_genre->setText(tmp_string);
00092 
00093     //Stream "public" checkbox
00094     stream_public->setChecked((bool)m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"stream_public")).toInt());
00095 
00096     //Encoding bitrate combobox
00097     tmp_index = comboBoxEncodingBitrate->findText(m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"bitrate")));
00098     if (tmp_index < 0) //Set default if invalid.
00099         tmp_index = 5; // 128 kbps
00100     comboBoxEncodingBitrate->setCurrentIndex(tmp_index);
00101 
00102     //Encoding format combobox
00103     tmp_index = comboBoxEncodingFormat->findText(m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"format")));
00104     if (tmp_index < 0) //Set default if invalid.
00105         tmp_index = 0;
00106     comboBoxEncodingFormat->setCurrentIndex(tmp_index);
00107 
00108     //Encoding channels combobox
00109     tmp_index = comboBoxEncodingChannels->findText(m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"channels")));
00110     if (tmp_index < 0) //Set default if invalid.
00111         tmp_index = 0;
00112     comboBoxEncodingChannels->setCurrentIndex(tmp_index);
00113 
00114     //"Enable custom metadata" checkbox
00115     enableCustomMetadata->setChecked((bool)m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"enable_metadata")).toInt());
00116 
00117     //Custom artist
00118     custom_artist->setText(m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"custom_artist")));
00119 
00120     //Custom title
00121     custom_title->setText(m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"custom_title")));
00122 
00123 
00124     slotApply();
00125 
00126     //recordControl->queueFromThread(RECORD_OFF); //make sure a corrupt config file won't cause us to record constantly
00127 
00128 }
00129 
00130 DlgPrefShoutcast::~DlgPrefShoutcast()
00131 {
00132     delete m_pUpdateShoutcastFromPrefs;
00133 }
00134 
00135 void DlgPrefShoutcast::slotUpdate()
00136 {
00137     enableLiveBroadcasting->setChecked((bool)m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"enabled")).toInt());
00138 }
00139 
00140 void DlgPrefShoutcast::slotApply()
00141 {
00142     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "enabled"),       ConfigValue(enableLiveBroadcasting->isChecked()));
00143     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "servertype"),    ConfigValue(comboBoxServerType->currentText()));
00144     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "mountpoint"),    ConfigValue(mountpoint->text()));
00145     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "host"),          ConfigValue(host->text()));
00146     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "port"),          ConfigValue(port->text()));
00147     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "login"),         ConfigValue(login->text()));
00148     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "password"),      ConfigValue(password->text()));
00149     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "stream_name"),   ConfigValue(stream_name->text()));
00150     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "stream_website"),ConfigValue(stream_website->text()));
00151     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "stream_desc"),   ConfigValue(stream_desc->toPlainText()));
00152     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "stream_genre"),  ConfigValue(stream_genre->text()));
00153     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "stream_public"), ConfigValue(stream_public->isChecked()));
00154     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "bitrate"),       ConfigValue(comboBoxEncodingBitrate->currentText()));
00155     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "format"),        ConfigValue(comboBoxEncodingFormat->currentText()));
00156     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "channels"),      ConfigValue(comboBoxEncodingChannels->currentText()));
00157     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY,"enable_metadata"),ConfigValue(enableCustomMetadata->isChecked()));
00158     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "custom_artist"), ConfigValue(custom_artist->text()));
00159     m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY, "custom_title"),  ConfigValue(custom_title->text()));
00160 
00161     //Tell the EngineShoutcast object to update with these values by toggling this control object.
00162     m_pUpdateShoutcastFromPrefs->slotSet(1.0f);
00163 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines