![]() |
Mixxx
|
00001 /*************************************************************************** 00002 dlgprefplaylist.cpp - description 00003 ------------------- 00004 begin : Thu Apr 17 2003 00005 copyright : (C) 2003 by Tue & Ken Haste Andersen 00006 email : haste@diku.dk 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #include "dlgprefplaylist.h" 00019 #include "library/promotracksfeature.h" 00020 #include "soundsourceproxy.h" 00021 //#include "plugindownloader.h" 00022 #include <QtCore> 00023 #include <QtGui> 00024 00025 #define MIXXX_ADDONS_URL "http://www.mixxx.org/wiki/doku.php/add-ons" 00026 00027 DlgPrefPlaylist::DlgPrefPlaylist(QWidget * parent, ConfigObject<ConfigValue> * _config) : QWidget(parent), Ui::DlgPrefPlaylistDlg() 00028 { 00029 config = _config; 00030 setupUi(this); 00031 slotUpdate(); 00032 checkbox_ID3_sync->setVisible(false); 00033 00034 /* 00035 m_pPluginDownloader = new PluginDownloader(this); 00036 00037 //Disable the M4A button if the plugin is present on disk. 00038 setupM4AButton(); 00039 00040 //Disable M4A Button after download completes successfully. 00041 connect(m_pPluginDownloader, SIGNAL(downloadFinished()), 00042 this, SLOT(slotM4ADownloadFinished())); 00043 00044 connect(m_pPluginDownloader, SIGNAL(downloadProgress(qint64, qint64)), 00045 this, SLOT(slotM4ADownloadProgress(qint64, qint64))); 00046 */ 00047 00048 // Connection 00049 connect(PushButtonBrowsePlaylist, SIGNAL(clicked()), this, SLOT(slotBrowseDir())); 00050 connect(LineEditSongfiles, SIGNAL(returnPressed()), this, SLOT(slotApply())); 00051 //connect(pushButtonM4A, SIGNAL(clicked()), this, SLOT(slotM4ACheck())); 00052 connect(pushButtonExtraPlugins, SIGNAL(clicked()), this, SLOT(slotExtraPlugins())); 00053 00054 #ifdef __IPOD__ 00055 // iPod related stuff 00056 connect(PushButtonDetectiPodMountPoint, SIGNAL(clicked()), this, SLOT(slotDetectiPodMountPoint())); 00057 connect(PushButtonBrowseiPodMountPoint, SIGNAL(clicked()), this, SLOT(slotBrowseiPodMountPoint())); 00058 connect(LineEditiPodMountPoint, SIGNAL(returnPressed()), this, SLOT(slotApply())); 00059 groupBoxiPod->setVisible(true); 00060 #endif 00061 00062 if (!PromoTracksFeature::isSupported(config)) 00063 { 00064 groupBoxBundledSongs->hide(); 00065 } 00066 00067 // plugins are loaded in src/main.cpp way early in boot so this is safe 00068 // here, doesn't need done at every slotUpdate 00069 QStringList plugins(SoundSourceProxy::supportedFileExtensionsByPlugins()); 00070 if (plugins.length() > 0) { 00071 pluginsLabel->setText(plugins.join(", ")); 00072 } 00073 } 00074 00075 DlgPrefPlaylist::~DlgPrefPlaylist() 00076 { 00077 } 00078 00079 void DlgPrefPlaylist::slotExtraPlugins() 00080 { 00081 QDesktopServices::openUrl(QUrl(MIXXX_ADDONS_URL)); 00082 } 00083 00084 /* 00085 void DlgPrefPlaylist::slotM4ADownloadProgress(qint64 bytesReceived, 00086 qint64 bytesTotal) 00087 { 00088 pushButtonM4A->setText(QString("%1\%").arg(100*(float)bytesReceived/bytesTotal, 0, 'g', 1)); 00089 } 00090 void DlgPrefPlaylist::slotM4ADownloadFinished() 00091 { 00092 //Disable the button after the download is finished. 00093 //We force it to be disabled because on Linux, gdebi-gtk 00094 //needs to be finished running before we know whether or not 00095 //the plugin is actually installed. :( 00096 setupM4AButton(true); 00097 } 00098 00099 void DlgPrefPlaylist::setupM4AButton(bool forceInstalled) 00100 { 00101 //If the M4A plugin is present on disk, disable the button 00102 if (m_pPluginDownloader->checkForM4APlugin() || forceInstalled) { 00103 pushButtonM4A->setChecked(true); 00104 pushButtonM4A->setEnabled(false); 00105 pushButtonM4A->setText(tr("Installed")); 00106 } 00107 } 00108 00109 void DlgPrefPlaylist::slotM4ACheck() 00110 { 00111 qDebug() << "slotM4ACheck"; 00112 00113 #ifdef __LINUX__ 00114 QFile version("/proc/version"); 00115 bool isUbuntu = true; 00116 if (version.open(QIODevice::ReadOnly)) 00117 { 00118 QByteArray rawLine = version.readAll(); 00119 QString versionString(rawLine); 00120 if (versionString.contains("Ubuntu", Qt::CaseInsensitive)) 00121 { 00122 isUbuntu = true; 00123 } 00124 } 00125 else { 00126 isUbuntu = false; 00127 } 00128 00129 if (!isUbuntu) 00130 { 00131 QMessageBox::information(this, tr("M4A Playback Plugin"), 00132 tr("The M4A playback plugin is currently" 00133 "unavailable for your Linux distribution." 00134 "Please download and compile Mixxx from " 00135 "source to enable M4A playback.")); 00136 } 00137 00138 #endif 00139 00140 if (!m_pPluginDownloader->checkForM4APlugin()) 00141 { 00142 m_pPluginDownloader->downloadM4APlugin(); 00143 } 00144 }*/ 00145 00146 void DlgPrefPlaylist::slotUpdate() 00147 { 00148 // Song path 00149 LineEditSongfiles->setText(config->getValueString(ConfigKey("[Playlist]","Directory"))); 00150 // iPod mount point 00151 LineEditiPodMountPoint->setText(config->getValueString(ConfigKey("[iPod]","MountPoint"))); 00152 //Bundled songs stat tracking 00153 checkBoxPromoStats->setChecked((bool)config->getValueString(ConfigKey("[Promo]","StatTracking")).toInt()); 00154 checkBox_library_scan->setChecked((bool)config->getValueString(ConfigKey("[Library]","RescanOnStartup")).toInt()); 00155 checkbox_ID3_sync->setChecked((bool)config->getValueString(ConfigKey("[Library]","WriteAudioTags")).toInt()); 00156 checkBox_use_relative_path->setChecked((bool)config->getValueString(ConfigKey("[Library]","UseRelativePathOnExport")).toInt()); 00157 00158 00159 } 00160 00161 void DlgPrefPlaylist::slotBrowseDir() 00162 { 00163 QString fd = QFileDialog::getExistingDirectory(this, tr("Choose music library directory"), 00164 config->getValueString(ConfigKey("[Playlist]","Directory"))); 00165 if (fd != "") 00166 { 00167 LineEditSongfiles->setText(fd); 00168 } 00169 } 00170 00171 void DlgPrefPlaylist::slotDetectiPodMountPoint() 00172 { 00173 QString iPodMountPoint; 00174 QFileInfoList mountpoints; 00175 #ifdef __WINDOWS__ 00176 // Windows iPod Detection 00177 mountpoints = QDir::drives(); 00178 #elif __LINUX__ 00179 // Linux 00180 mountpoints = QDir("/media").entryInfoList(); 00181 mountpoints += QDir("/mnt").entryInfoList(); 00182 #elif __OSX__ 00183 // Mac OSX 00184 mountpoints = QDir("/Volumes").entryInfoList(); 00185 #endif 00186 00187 QListIterator<QFileInfo> i(mountpoints); 00188 QFileInfo mp; 00189 while (i.hasNext()) { 00190 mp = (QFileInfo) i.next(); 00191 qDebug() << "mp:" << mp.filePath(); 00192 if (QDir( QString(mp.filePath() + "/iPod_Control") ).exists() ) { 00193 qDebug() << "iPod found at" << mp.filePath(); 00194 00195 // Multiple iPods 00196 if (!iPodMountPoint.isEmpty()) { 00197 int ret = QMessageBox::warning(this, tr("Multiple iPods Detected"), 00198 tr("Mixxx has detected another iPod. \n\n")+ 00199 tr("Choose Yes to use the newly found iPod @ ")+ mp.filePath()+ 00200 tr(" or to continue to search for other iPods. \n")+ 00201 tr("Choose No to use the existing iPod @ ")+ iPodMountPoint+ 00202 tr( " and end detection. \n"), 00203 QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); 00204 if (ret == QMessageBox::No) { 00205 break; 00206 } 00207 } 00208 00209 iPodMountPoint = mp.filePath() + "/"; 00210 } 00211 } 00212 if (!iPodMountPoint.isEmpty()) { 00213 LineEditiPodMountPoint->setText(iPodMountPoint); 00214 } 00215 } 00216 00217 void DlgPrefPlaylist::slotBrowseiPodMountPoint() 00218 { 00219 00220 QString fd = QFileDialog::getExistingDirectory(this, tr("Choose iPod mount point"), 00221 config->getValueString(ConfigKey("[iPod]","MountPoint"))); 00222 if (fd != "") 00223 { 00224 LineEditiPodMountPoint->setText(fd); 00225 } 00226 } 00227 00228 00229 00230 void DlgPrefPlaylist::slotApply() 00231 { 00232 00233 config->set(ConfigKey("[Promo]","StatTracking"), 00234 ConfigValue((int)checkBoxPromoStats->isChecked())); 00235 00236 config->set(ConfigKey("[Library]","RescanOnStartup"), 00237 ConfigValue((int)checkBox_library_scan->isChecked())); 00238 00239 config->set(ConfigKey("[Library]","WriteAudioTags"), 00240 ConfigValue((int)checkbox_ID3_sync->isChecked())); 00241 00242 config->set(ConfigKey("[Library]","UseRelativePathOnExport"), 00243 ConfigValue((int)checkBox_use_relative_path->isChecked())); 00244 00245 00246 config->Save(); 00247 00248 // Update playlist if path has changed 00249 if (LineEditSongfiles->text() != config->getValueString(ConfigKey("[Playlist]","Directory"))) 00250 { 00251 // Check for valid directory and put up a dialog if invalid!!! 00252 00253 config->set(ConfigKey("[Playlist]","Directory"), LineEditSongfiles->text()); 00254 00255 // Save preferences 00256 config->Save(); 00257 00258 // Emit apply signal 00259 emit(apply()); 00260 } 00261 if (LineEditiPodMountPoint->text() != config->getValueString(ConfigKey("[iPod]","MountPoint"))) 00262 { 00263 config->set(ConfigKey("[iPod]","MountPoint"), LineEditiPodMountPoint->text()); 00264 // Save preferences 00265 config->Save(); 00266 // Emit apply signal 00267 emit(apply()); 00268 } 00269 }