Mixxx

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

Go to the documentation of this file.
00001 #include <QDesktopServices>
00002 #include <QDateTime>
00003 
00004 #include "widget/wwidget.h"
00005 #include "widget/wskincolor.h"
00006 #include "widget/wtracktableview.h"
00007 #include "controlobject.h"
00008 #include "controlobjectthreadmain.h"
00009 #include "library/trackcollection.h"
00010 
00011 #
00012 #include "dlgrecording.h"
00013 
00014 
00015 
00016 DlgRecording::DlgRecording(QWidget* parent, ConfigObject<ConfigValue>* pConfig,
00017                            TrackCollection* pTrackCollection,
00018                            RecordingManager* pRecordingManager, MixxxKeyboard* pKeyboard)
00019             : QWidget(parent), Ui::DlgRecording(),
00020             m_pConfig(pConfig),
00021             m_pTrackCollection(pTrackCollection),
00022             m_browseModel(this, m_pTrackCollection, pRecordingManager),
00023             m_proxyModel(&m_browseModel),
00024             m_pRecordingManager(pRecordingManager)
00025 {
00026     setupUi(this);
00027     m_pTrackTableView = new WTrackTableView(this, pConfig, m_pTrackCollection);
00028     m_pTrackTableView->installEventFilter(pKeyboard);
00029 
00030     connect(m_pTrackTableView, SIGNAL(loadTrack(TrackPointer)),
00031             this, SIGNAL(loadTrack(TrackPointer)));
00032     connect(m_pTrackTableView, SIGNAL(loadTrackToPlayer(TrackPointer, QString)),
00033             this, SIGNAL(loadTrackToPlayer(TrackPointer, QString)));
00034 
00035     connect(m_pRecordingManager, SIGNAL(isRecording(bool)),
00036             this, SLOT(slotRecordingEnabled(bool)));
00037     connect(m_pRecordingManager, SIGNAL(bytesRecorded(long)),
00038             this, SLOT(slotBytesRecorded(long)));
00039 
00040     QBoxLayout* box = dynamic_cast<QBoxLayout*>(layout());
00041     Q_ASSERT(box); //Assumes the form layout is a QVBox/QHBoxLayout!
00042     box->removeWidget(m_pTrackTablePlaceholder);
00043     m_pTrackTablePlaceholder->hide();
00044     box->insertWidget(1, m_pTrackTableView);
00045 
00046 
00047     m_recordingDir = m_pRecordingManager->getRecordingDir();
00048 
00049     m_proxyModel.setFilterCaseSensitivity(Qt::CaseInsensitive);
00050     m_proxyModel.setSortCaseSensitivity(Qt::CaseInsensitive);
00051 
00052     m_browseModel.setPath(m_recordingDir);
00053     m_pTrackTableView->loadTrackModel(&m_proxyModel);
00054 
00055     //Sort by the position column and lock it
00056     m_pTrackTableView->sortByColumn(0, Qt::AscendingOrder);
00057     m_pTrackTableView->setSortingEnabled(false);
00058 
00059     connect(pushButtonRecording, SIGNAL(toggled(bool)),
00060             this,  SLOT(toggleRecording(bool)));
00061     label->setText(tr("Start recording here ..."));
00062 
00063 }
00064 
00065 DlgRecording::~DlgRecording()
00066 {
00067 
00068 }
00069 
00070 void DlgRecording::onShow()
00071 {
00072     m_browseModel.setPath(m_recordingDir);
00073 }
00074 
00075 void DlgRecording::setup(QDomNode node)
00076 {
00077 
00078     QPalette pal = palette();
00079 
00080     // Row colors
00081     if (!WWidget::selectNode(node, "BgColorRowEven").isNull() &&
00082         !WWidget::selectNode(node, "BgColorRowUneven").isNull()) {
00083         QColor r1;
00084         r1.setNamedColor(WWidget::selectNodeQString(node, "BgColorRowEven"));
00085         r1 = WSkinColor::getCorrectColor(r1);
00086         QColor r2;
00087         r2.setNamedColor(WWidget::selectNodeQString(node, "BgColorRowUneven"));
00088         r2 = WSkinColor::getCorrectColor(r2);
00089 
00090         // For now make text the inverse of the background so it's readable In
00091         // the future this should be configurable from the skin with this as the
00092         // fallback option
00093         QColor text(255 - r1.red(), 255 - r1.green(), 255 - r1.blue());
00094 
00095         //setAlternatingRowColors ( true );
00096 
00097         QColor fgColor;
00098         fgColor.setNamedColor(WWidget::selectNodeQString(node, "FgColor"));
00099         fgColor = WSkinColor::getCorrectColor(fgColor);
00100 
00101         pal.setColor(QPalette::Base, r1);
00102         pal.setColor(QPalette::AlternateBase, r2);
00103         pal.setColor(QPalette::Text, text);
00104         pal.setColor(QPalette::WindowText, fgColor);
00105 
00106     }
00107 
00108     setPalette(pal);
00109 
00110     pushButtonRecording->setPalette(pal);
00111     //m_pTrackTableView->setPalette(pal); //Since we're getting this passed into us already created,
00112                                           //shouldn't need to set the palette.
00113 }
00114 
00115 void DlgRecording::onSearchStarting()
00116 {
00117 }
00118 
00119 void DlgRecording::onSearchCleared()
00120 {
00121 }
00122 void DlgRecording::refreshBrowseModel(){
00123      m_browseModel.setPath(m_recordingDir);
00124 }
00125 
00126 void DlgRecording::onSearch(const QString& text)
00127 {
00128     m_proxyModel.search(text);
00129 }
00130 
00131 void DlgRecording::loadSelectedTrack() {
00132     m_pTrackTableView->loadSelectedTrack();
00133 }
00134 
00135 void DlgRecording::loadSelectedTrackToGroup(QString group) {
00136     m_pTrackTableView->loadSelectedTrackToGroup(group);
00137 }
00138 
00139 void DlgRecording::moveSelection(int delta) {
00140     m_pTrackTableView->moveSelection(delta);
00141 }
00142 
00143 void DlgRecording::toggleRecording(bool toggle)
00144 {
00145     Q_UNUSED(toggle);
00146     if (!m_pRecordingManager->isRecordingActive()) //If recording is enabled
00147     {
00148         //pushButtonRecording->setText(tr("Stop Recording"));
00149         m_pRecordingManager->startRecording();
00150     }
00151     else if(m_pRecordingManager->isRecordingActive()) //If we disable recording
00152     {
00153         //pushButtonRecording->setText(tr("Start Recording"));
00154         m_pRecordingManager->stopRecording();
00155     }
00156 }
00157 void DlgRecording::slotRecordingEnabled(bool isRecording)
00158 {
00159     if(isRecording){
00160         pushButtonRecording->setText((tr("Stop Recording")));
00161         //This will update the recorded track table view
00162         m_browseModel.setPath(m_recordingDir);
00163     }
00164     else{
00165         pushButtonRecording->setText((tr("Start Recording")));
00166         label->setText("Start recording here ...");
00167     }
00168 
00169 }
00171 void DlgRecording::slotBytesRecorded(long bytes)
00172 {
00173     double megabytes = bytes / 1048575.0f;
00174     QString byteStr = QString::number(megabytes,'f',2);
00175     QString text = "Recording to file: " +m_pRecordingManager->getRecordingFile();
00176     text.append(" (" +byteStr+ " MB written)");
00177     label->setText(text);
00178 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines