![]() |
Mixxx
|
00001 /*************************************************************************** 00002 LibraryScannerDlg.cpp - shows library scanning 00003 progress 00004 ------------------- 00005 begin : 11/27/2007 00006 copyright : (C) 2007 Albert Santoni and Adam Davison 00007 email : gamegod \a\t users.sf.net 00008 ***************************************************************************/ 00009 00010 /*************************************************************************** 00011 * * 00012 * This program is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU General Public License as published by * 00014 * the Free Software Foundation; either version 2 of the License, or * 00015 * (at your option) any later version. * 00016 * * 00017 ***************************************************************************/ 00018 00019 #include <QtCore> 00020 #include <QtDebug> 00021 #include <QtGui> 00022 #include "libraryscannerdlg.h" 00023 00024 LibraryScannerDlg::LibraryScannerDlg(QWidget * parent, Qt::WindowFlags f) : 00025 QWidget(parent, f) 00026 { 00027 m_bCancelled = false; 00028 00029 QVBoxLayout* pLayout = new QVBoxLayout(this); 00030 00031 setWindowTitle(tr("Library Scanner")); 00032 QLabel* pLabel = new QLabel(tr("It's taking Mixxx a minute to scan your music library, please wait..."),this); 00033 pLayout->addWidget(pLabel); 00034 00035 QPushButton* pCancel = new QPushButton(tr("Cancel"), this); 00036 connect(pCancel, SIGNAL(clicked()), 00037 this, SLOT(slotCancel())); 00038 pLayout->addWidget(pCancel); 00039 00040 QLabel* pCurrent = new QLabel(this); 00041 pCurrent->setMaximumWidth(600); 00042 pCurrent->setWordWrap(true); 00043 connect(this, SIGNAL(progress(QString)), 00044 pCurrent, SLOT(setText(QString))); 00045 pLayout->addWidget(pCurrent); 00046 setLayout(pLayout); 00047 00048 m_timer.start(); 00049 } 00050 00051 LibraryScannerDlg::~LibraryScannerDlg() 00052 { 00053 } 00054 00055 void LibraryScannerDlg::slotUpdate(QString path) { 00056 //qDebug() << "LibraryScannerDlg slotUpdate" << m_timer.elapsed(); 00057 if (!m_bCancelled && m_timer.elapsed() > 2000) { 00058 setVisible(true); 00059 } 00060 00061 if (isVisible()) { 00062 QString status = "Scanning: " + path; 00063 emit(progress(status)); 00064 } 00065 } 00066 00067 void LibraryScannerDlg::slotCancel() 00068 { 00069 qDebug() << "Cancelling library scan..."; 00070 m_bCancelled = true; 00071 00072 emit(scanCancelled()); 00073 00074 // Need to use close() or else if you close the Mixxx window and then hit 00075 // Cancel, Mixxx will not shutdown. 00076 close(); 00077 } 00078 00079 void LibraryScannerDlg::slotScanFinished() 00080 { 00081 m_bCancelled = true; //Raise this flag to prevent any 00082 //latent slotUpdates() from showing the dialog again. 00083 00084 // Need to use close() or else if you close the Mixxx window and then hit 00085 // Cancel, Mixxx will not shutdown. 00086 close(); 00087 }