void QWifiManagerPrivateMac::parseResults() { QString reply(scan->readAllStandardOutput()); QStringList lines = reply.split("\n"); QString ssid, bssid, enc; int level; clearPreviousScanResults(); if ( lines.size() <= 1 ) { emit scanFinished(QWifiManager::SCAN_OK); return; } int ssidLimit = lines.at(0).indexOf("BSSID"); if (ssidLimit == -1 ) { emit scanFinished(QWifiManager::SCAN_OK); return; } for (int i = 1; i < lines.size(); ++i) { ssid = lines.at(i).left(ssidLimit).trimmed(); if ( ssid.length() == 0) continue; bssid = lines.at(i).mid(ssidLimit,17).toUpper(); level = lines.at(i).mid(ssidLimit+18,4).trimmed().toInt() + 100; if ( lines.at(i).contains("PSK") ) enc = "PSK"; else if ( lines.at(i).contains("EAP") ) enc = "EAP"; else if ( lines.at(i).contains("WEP") ) enc = "WEP"; else enc = "Open"; scanResults.append(QSharedPointer<QScanResult>(new QScanResult(ssid, bssid, enc, 0, level))); } emit scanFinished(QWifiManager::SCAN_OK); }
DeviceDiscoveryDialog::DeviceDiscoveryDialog(QWidget *parent) : QDialog(parent), discoveryAgent(new QBluetoothDeviceDiscoveryAgent), localDevice(new QBluetoothLocalDevice), ui(new Ui_DeviceDiscovery) { ui->setupUi(this); #if defined (Q_OS_SYMBIAN) || defined(Q_OS_WINCE) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) setWindowState(Qt::WindowFullScreen); #endif connect(ui->inquiryType, SIGNAL(toggled(bool)), this, SLOT(setGeneralUnlimited(bool))); connect(ui->scan, SIGNAL(clicked()), this, SLOT(startScan())); connect(discoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)), this, SLOT(addDevice(const QBluetoothDeviceInfo&))); connect(discoveryAgent, SIGNAL(finished()), this, SLOT(scanFinished())); connect(ui->list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemActivated(QListWidgetItem*))); connect(localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)), this, SLOT(hostModeStateChanged(QBluetoothLocalDevice::HostMode))); hostModeStateChanged(localDevice->hostMode()); // add context menu for devices to be able to pair device ui->list->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->list, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(displayPairingMenu(QPoint))); connect(localDevice, SIGNAL(pairingFinished(const QBluetoothAddress&, QBluetoothLocalDevice::Pairing)) , this, SLOT(pairingDone(const QBluetoothAddress&, QBluetoothLocalDevice::Pairing))); }
void MapGraphicsView::setMapScene(MapGraphicsScene *scene) { setScene(scene); m_gs = scene; connect(m_gs, SIGNAL(scanResultsAvailable(QList<WifiDataResult>)), this, SLOT(scanFinished(QList<WifiDataResult>))); }
void QConnmanEngine::initialize() { QMutexLocker locker(&mutex); connect(ofonoManager,SIGNAL(modemChanged()),this,SLOT(changedModem())); ofonoNetwork = new QOfonoNetworkRegistrationInterface(ofonoManager->currentModem(),this); ofonoContextManager = new QOfonoDataConnectionManagerInterface(ofonoManager->currentModem(),this); connect(ofonoContextManager,SIGNAL(roamingAllowedChanged(bool)),this,SLOT(reEvaluateCellular())); connect(connmanManager,SIGNAL(servicesChanged(ConnmanMapList, QList<QDBusObjectPath>)), this, SLOT(updateServices(ConnmanMapList, QList<QDBusObjectPath>))); connect(connmanManager,SIGNAL(servicesReady(QStringList)),this,SLOT(servicesReady(QStringList))); connect(connmanManager,SIGNAL(scanFinished()),this,SLOT(finishedScan())); foreach (const QString &servPath, connmanManager->getServices()) { addServiceConfiguration(servPath); } Q_EMIT updateCompleted(); QSettings confFile(QStringLiteral("nemomobile"),QStringLiteral("connectionagent")); inotifyFileDescriptor = ::inotify_init(); inotifyWatcher = ::inotify_add_watch(inotifyFileDescriptor, QFile::encodeName(confFile.fileName()), IN_MODIFY); if (inotifyWatcher > 0) { QSocketNotifier *notifier = new QSocketNotifier(inotifyFileDescriptor, QSocketNotifier::Read, this); connect(notifier, SIGNAL(activated(int)), this, SLOT(inotifyActivated())); }
void frmNapiProjektUpload::pbScanClicked() { if(!scanThread.isRunning()) { ui.leSelectDirectory->setEnabled(false); ui.pbSelectDirectory->setEnabled(false); ui.pbScan->setText(tr("Przerwij")); ui.lbAction->setText(tr("Skanowanie katalogów...")); ui.lbFoldersCount->setEnabled(false); ui.lbFoldersCount->setText(tr("Katalogów: <b>0</b>")); ui.lbMoviesCount->setEnabled(false); ui.lbMoviesCount->setText(tr("Filmów: <b>0</b>")); ui.lbSubtitlesCount->setEnabled(false); ui.lbSubtitlesCount->setText(tr("Napisów: <b>0</b>")); ui.pbProgress->setEnabled(false); ui.pbUpload->setEnabled(false); ui.cbFollowSymLinks->setEnabled(false); scanThread.setSearchPath(ui.leSelectDirectory->text()); scanThread.setFollowSymLinks(ui.cbFollowSymLinks->isChecked()); scanThread.start(); } else { scanThread.requestAbort(); ui.lbAction->setText(tr("Przerywanie skanowania...")); ui.pbScan->setEnabled(false); qApp->processEvents(); scanThread.wait(); ui.pbScan->setEnabled(true); scanFinished(false); } }
Connect_Bluetooth::Connect_Bluetooth(QWidget *parent) : QDialog(parent), ui(new Ui::Connect_Bluetooth) { ui->setupUi(this); discoveryAgent = new QBluetoothDeviceDiscoveryAgent(); connect(ui->inquiryType, SIGNAL(toggled(bool)), this, SLOT(setGeneralUnlimited(bool))); connect(ui->scan, SIGNAL(clicked()), this, SLOT(startScan())); connect(discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), this, SLOT(addDevice(QBluetoothDeviceInfo))); connect(discoveryAgent, SIGNAL(finished()), this, SLOT(scanFinished())); connect(ui->list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemActivated(QListWidgetItem*))); /* connect(localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)), this, SLOT(hostModeStateChanged(QBluetoothLocalDevice::HostMode))); hostModeStateChanged(localDevice->hostMode()); // add context menu for devices to be able to pair device ui->list->setContextMenuPolicy(Qt::CustomContextMenu); */ }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->listView->setGridSize(QSize(cGridSize, cGridSize)); ui->listView->setIconSize(QSize(cIconSize, cIconSize)); QList<thumb> *testList = new QList<thumb>(/*createList()*/); model = new ImagesModel(testList, this); ui->listView->setModel(model); mProgressBar = new QProgressBar(); mProgressBar->setMinimum(0); mProgressBar->setValue(0); mProgressBar->setVisible(false); ui->statusBar->addPermanentWidget(mProgressBar); qRegisterMetaType<thumb>("thumb"); connect(&mThread, SIGNAL(sendThumb(thumb)), this, SLOT(addItem(thumb))); connect(&mThread, SIGNAL(maxFilesCountEvaluated(int)), mProgressBar, SLOT(setMaximum(int))); connect(&mThread, SIGNAL(scanFinished()), mProgressBar, SLOT(hide())); mThread.compute("/home/luxa/Pictures/Photos"); }
void Tst_qofonoTest::testScan() { QOfonoManager manager; QOfonoModem modem; modem.setModemPath(manager.modems()[0]); QOfonoNetworkRegistration netreg; netreg.setModemPath(manager.modems()[0]); QSignalSpy spy_scanFinished(&netreg, SIGNAL(scanFinished())); QSignalSpy spy_scanError(&netreg, SIGNAL(scanError(QString))); netreg.scan(); ::waitForSignal(&netreg, SIGNAL(scanFinished()), 1000 * 500); QCOMPARE(spy_scanError.count(),0); QCOMPARE(spy_scanFinished.count(),1); }
void Scanner_Master::moveStep() { emit moveStepperToTarget(MonoPos, MonoPos + (direction == true)?1:(-1)); MonoPos = MonoPos + (direction == true)?1:(-1); if(MonoPos == stoppos) { emit scanFinished(); emit scanInterrupted(); } }
void LibraryManagerPrivate::fullScan() { cancel = false; mustClean = false; totalFiles = 0; currentFile = 0; emit scanStarted(); DataBase::instance()->clean(); QStringList paths = LibraryManager::searchPaths(); for ( QString path : paths ) { QDirIterator it(path, QDir::Files | QDir::NoDotAndDotDot, QDirIterator::FollowSymlinks | QDirIterator::Subdirectories); while ( it.hasNext() ) { totalFiles++; it.next(); } } for ( QString path : paths ) { folderScan(path); QDirIterator it(path, QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::FollowSymlinks | QDirIterator::Subdirectories); while ( it.hasNext() ) { if ( cancel ) { mustClean = true; emit scanFinished(); return; } folderScan( it.next() ); } } totalFiles = 0; currentFile = 0; mustClean = true; emit scanFinished(); }
/** * @brief FileFinder::scanProject * @param HashProject hashproject * * Scans the source directory set for the project, and emits the * signal fileFound(File) for all found files. * No signals are sent for directories. * * The HashProject::Settings configuration settings that can be defined * for this function are: * - scanimmediately: Calculate hash sum when a file has been found. * If set to false only the filename will be added. * - blockinghashcalc: If scanimmediately is true, calculate the hash sum * in this thread. Otherwise it may run in a different thread. * - algorithm: Which algorithm should be used for the calculation. */ void FileFinder::scanProject(HashProject* hashproject) { aborted = false; if (!hashproject) { emit scanFinished(); return; } if (!hashproject->getSourceDirectory()->isValid()) { emit scanFinished(); return; } HashProject::Settings settings = hashproject->getSettings(); QString basepath = hashproject->getSourceDirectory()->getPath(); if (basepath.right(1) != QDir::separator()) { basepath += QDir::separator(); } QDirIterator iterator(basepath, QDirIterator::Subdirectories); while (iterator.hasNext()) { if (aborted) { // Scanning was aborted by a separate thread. emit scanFinished(); return; } iterator.next(); if (!iterator.fileInfo().isDir()) { // Not a directory. Create a new File object and emit it. QString filename = iterator.filePath(); HashProject::File filenode; filenode.filename = filename.remove(0, basepath.length()); filenode.filesize = iterator.fileInfo().size(); if (settings.blockinghashcalc && settings.scanimmediately) { filenode.hash = hasher.hashFile(-1, basepath, filenode, settings.algorithm); filenode.algorithm = settings.algorithm; } emit fileFound(filenode, false); } } emit scanFinished(); }
RgAnalysisManager::RgAnalysisManager (LocalCollection *coll, QObject *parent) : QObject { parent } , Coll_ { coll } { connect (Coll_, SIGNAL (scanFinished ()), this, SLOT (handleScanFinished ())); XmlSettingsManager::Instance ().RegisterObject ("AutobuildRG", this, "handleScanFinished"); }
void SMPPPDCSPrefs::determineCSType() { // while we search, we'll disable the button autoCSTest->setEnabled(false); //kapp->processEvents(); /* broadcast network for a smpppd. If one is available set to smpppd method */ SMPPPDSearcher searcher; m_curSearcher = &searcher; connect(&searcher, SIGNAL(smpppdFound(const QString&)), this, SLOT(smpppdFound(const QString&))); connect(&searcher, SIGNAL(smpppdNotFound()), this, SLOT(smpppdNotFound())); connect(&searcher, SIGNAL(scanStarted(uint)), this, SLOT(scanStarted(uint))); connect(&searcher, SIGNAL(scanProgress(uint)), this, SLOT(scanProgress(uint))); connect(&searcher, SIGNAL(scanFinished()), this, SLOT(scanFinished())); searcher.searchNetwork(); m_curSearcher = NULL; }
void TechnologyModel::doUpdateTechnologies() { NetworkTechnology *newTech = m_manager->getTechnology(m_techname); if (m_tech == newTech) return; bool oldPowered = false; bool oldConnected = false; if (m_tech) { oldPowered = m_tech->powered(); oldConnected = m_tech->connected(); disconnect(m_tech, SIGNAL(poweredChanged(bool)), this, SLOT(changedPower(bool))); disconnect(m_tech, SIGNAL(connectedChanged(bool)), this, SLOT(changedConnected(bool))); disconnect(m_tech, SIGNAL(scanFinished()), this, SLOT(finishedScan())); } if (m_scanning) { m_scanning = false; Q_EMIT scanningChanged(m_scanning); } m_tech = newTech; if (m_tech) { connect(m_tech, SIGNAL(poweredChanged(bool)), this, SLOT(changedPower(bool))); connect(m_tech, SIGNAL(connectedChanged(bool)), this, SLOT(changedConnected(bool))); connect(m_tech, SIGNAL(scanFinished()), this, SLOT(finishedScan())); bool b = m_tech->powered(); if (b != oldPowered) Q_EMIT poweredChanged(b); b = m_tech->connected(); if (b != oldConnected) Q_EMIT connectedChanged(b); } else { if (oldPowered)
void QConnectionManager::connectToType(const QString &type) { qDebug() << type; currentType = type; QString techPath = netman->technologyPathForType(type); if (techPath.isEmpty()) { Q_EMIT errorReported("","Type not valid"); return; } NetworkTechnology netTech; netTech.setPath(techPath); if (!netTech.powered()) { // user has indicated they want a connection netTech.setPowered(true); } QStringList servicesList = netman->servicesList(type); bool needConfig = false; if (servicesList.isEmpty()) { if (type == "wifi") { QObject::connect(&netTech,SIGNAL(scanFinished()),this,SLOT(onScanFinished())); netTech.scan(); } else { needConfig = true; // Q_EMIT errorReported("Service not found"); ?? do we want to report an error } } else { currentType = ""; Q_FOREACH (const QString path, servicesList) { // try harder with cell. a favorite is one that has been connected // if there is a context configured but not yet connected, try to connect anyway if (servicesMap.contains(path) && (servicesMap.value(path)->favorite() || servicesMap.value(path)->type() == "cellular")) { connectToNetworkService(path); needConfig = false; return; } else { needConfig = true; } } } if (needConfig) { Q_EMIT configurationNeeded(type); } }
void DirScaner::run() { QDirIterator iter(m_path); while (iter.hasNext()) { if (m_canceled == true) break; iter.next(); emit fileFounded(iter.fileInfo(), this); } emit scanFinished(this); }
void testQOfonoNetworkOperator() { QSignalSpy scanFinished(m, SIGNAL(scanFinished())); QSignalSpy networkOperatorsChanged(m, SIGNAL(networkOperatorsChanged(QStringList))); m->scan(); QTRY_COMPARE(scanFinished.count(), 1); scanFinished.takeFirst(); QTRY_COMPARE(networkOperatorsChanged.count(), 1); QStringList opIdList = networkOperatorsChanged.takeFirst().at(0).toStringList(); QVERIFY(opIdList.count() > 0); int op1 = -1; int op2 = -1; QList<QOfonoNetworkOperator *> opList; foreach(QString opId, opIdList) { QOfonoNetworkOperator *op = new QOfonoNetworkOperator(this); op->setOperatorPath(opId); opList << op; if (op1 == -1 && op->status() == "current") op1 = opIdList.indexOf(opId); if (op2 == -1 && op->status() == "available") op2 = opIdList.indexOf(opId); }
/** * @brief MainWindow::createWorkerThreads * * Creates the objects with the processing algorithms that are to be run i separate threads. * As of now they are one instance of Hasher and one instad of FileFinder. * Each instance is put in a QThread. * * To prevent race conditions, before doing any processing (calling a slot in the threads) * a call to processWorkStarted() must be made. When the threads are finished with the actions, * they will announce this with a signal to MainWindow::actionStopped. */ void MainWindow::createWorkerThreads() { hasher = new Hasher; filefinder = new FileFinder; hasherthread = new QThread; filefinderthread = new QThread; filefinder->moveToThread(filefinderthread); hasher->moveToThread(hasherthread); filefinderthread->start(); hasherthread->start(); connect(this, SIGNAL(findFiles(HashProject*)), filefinder, SLOT(scanProject(HashProject*))); connect(this, SIGNAL(hashFiles(HashProject*, bool, QString)), hasher, SLOT(hashProject(HashProject*, bool, QString))); connect(filefinder, SIGNAL(fileFound(HashProject::File, bool)), filelist, SLOT(addFile(HashProject::File, bool))); connect(filelist, SIGNAL(hashFile(int, QString, HashProject::File, QString)), hasher, SLOT(hashFile(int, QString, HashProject::File, QString))); connect(hasher, SIGNAL(fileHashCalculated(int, QString, QString, bool)), filelist, SLOT(fileHashCalculated(int, QString, QString, bool))); /** * Signal path between the three threads when announcing that they are finished: * Example, scanning for files using filefinder: * filefinder.scanFinished -> filelist.fileAdditionFinished -> hasher.scanFinished -> filelist.processingDone -> mainwindow.actionStopped * Example, hashing files after dropping them: * filelist.fileAdditionFinished -> hasher.scanFinished -> filelist.processingDone -> mainwindow.actionStopped * Example, hashing a project: * hasher.hashproject -> hasher.scanFinished -> filelist.processingDone -> mainwindow.actionStopped */ connect(this, SIGNAL(processWorkStarted()), hasher, SLOT(startProcessWork())); connect(filefinder, SIGNAL(scanFinished()), filelist, SLOT(fileAdditionFinished())); connect(filelist, SIGNAL(noMoreFileJobs()), hasher, SLOT(noMoreFiles())); connect(hasher, SIGNAL(scanFinished()), filelist, SLOT(hashingFinished())); connect(filelist, SIGNAL(processingDone()), this, SLOT(actionStopped())); connect(hasher, SIGNAL(progressstatus(int)), progressbar, SLOT(setValue(int))); }
void ScanThread::run() { abort = false; folders = movies = subtitles = 0; fileList.clear(); visited.clear(); searchFilters.clear(); searchFilters << "*.avi" << "*.asf" << "*.divx" << "*.mkv" << "*.mov" << "*.mp4" << "*.mpeg" << "*.mpg" << "*.ogm" << "*.rm" << "*.rmvb" << "*.wmv"; QDir::Filters filters = QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Readable | QDir::Hidden; if(!followSymLinks) filters |= QDir::NoSymLinks; emit scanFinished(doScan(searchPath, filters)); }
void KnownPluginList::scanAndAddDragAndDroppedFiles (AudioPluginFormatManager& formatManager, const StringArray& files, OwnedArray <PluginDescription>& typesFound) { for (int i = 0; i < files.size(); ++i) { const String filenameOrID (files[i]); bool found = false; for (int j = 0; j < formatManager.getNumFormats(); ++j) { AudioPluginFormat* const format = formatManager.getFormat (j); if (format->fileMightContainThisPluginType (filenameOrID) && scanAndAddFile (filenameOrID, true, typesFound, *format)) { found = true; break; } } if (! found) { const File f (filenameOrID); if (f.isDirectory()) { StringArray s; { Array<File> subFiles; f.findChildFiles (subFiles, File::findFilesAndDirectories, false); for (int j = 0; j < subFiles.size(); ++j) s.add (subFiles.getReference(j).getFullPathName()); } scanAndAddDragAndDroppedFiles (formatManager, s, typesFound); } } } scanFinished(); }
LibraryScanner::LibraryScanner(TrackCollection* collection) : m_pCollection(collection), m_pProgress(NULL), m_libraryHashDao(m_database), m_cueDao(m_database), m_playlistDao(m_database), m_crateDao(m_database), m_directoryDao(m_database), m_analysisDao(m_database, collection->getConfig()), m_trackDao(m_database, m_cueDao, m_playlistDao, m_crateDao, m_analysisDao,m_directoryDao, collection->getConfig()), // Don't initialize m_database here, we need to do it in run() so the DB // conn is in the right thread. m_extensionFilter(SoundSourceProxy::supportedFileExtensionsRegex(), Qt::CaseInsensitive), m_bCancelLibraryScan(false) { qDebug() << "Constructed LibraryScanner"; // Force the GUI thread's TrackInfoObject cache to be cleared when a library // scan is finished, because we might have modified the database directly // when we detected moved files, and the TIOs corresponding to the moved // files would then have the wrong track location. connect(this, SIGNAL(scanFinished()), &(collection->getTrackDAO()), SLOT(clearCache())); // The "Album Artwork" folder within iTunes stores Album Arts. // It has numerous hundreds of sub folders but no audio files // We put this folder on a "black list" // On Windows, the iTunes folder is contained within the standard music folder // Hence, Mixxx will scan the "Album Arts folder" for standard users which is wasting time QString iTunesArtFolder = QDir::toNativeSeparators( QDesktopServices::storageLocation(QDesktopServices::MusicLocation) + "/iTunes/Album Artwork" ); m_directoriesBlacklist << iTunesArtFolder; qDebug() << "iTunes Album Art path is:" << iTunesArtFolder; #ifdef __WINDOWS__ //Blacklist the _Serato_ directory that pollutes "My Music" on Windows. QString seratoDir = QDir::toNativeSeparators( QDesktopServices::storageLocation(QDesktopServices::MusicLocation) + "/_Serato_" ); m_directoriesBlacklist << seratoDir; #endif }
void LocalCollection::handleScanFinished () { auto future = Watcher_->future (); QList<MediaInfo> newInfos, existingInfos; for (const auto& info : future) { const auto& path = info.LocalPath_; if (path.isEmpty ()) continue; if (PresentPaths_.contains (path)) existingInfos << info; else { newInfos << info; PresentPaths_ += path; } } emit scanFinished (); auto newArts = Storage_->AddToCollection (newInfos); HandleNewArtists (newArts); if (!NewPathsQueue_.isEmpty ()) InitiateScan (NewPathsQueue_.takeFirst ()); else if (UpdateNewTracks_) { const auto& artistsMsg = tr ("%n new artist(s)", 0, UpdateNewArtists_); const auto& albumsMsg = tr ("%n new album(s)", 0, UpdateNewAlbums_); const auto& tracksMsg = tr ("%n new track(s)", 0, UpdateNewTracks_); const auto& msg = tr ("Local collection updated: %1, %2, %3.") .arg (artistsMsg) .arg (albumsMsg) .arg (tracksMsg); Core::Instance ().SendEntity (Util::MakeNotification ("LMP", msg, PInfo_)); UpdateNewArtists_ = UpdateNewAlbums_ = UpdateNewTracks_ = 0; } HandleExistingInfos (existingInfos); }
void QConnmanEngine::initialize() { QMutexLocker locker(&mutex); connect(ofonoManager,SIGNAL(modemChanged()),this,SLOT(changedModem())); ofonoNetwork = new QOfonoNetworkRegistrationInterface(ofonoManager->currentModem(),this); ofonoContextManager = new QOfonoDataConnectionManagerInterface(ofonoManager->currentModem(),this); connect(ofonoContextManager,SIGNAL(roamingAllowedChanged(bool)),this,SLOT(reEvaluateCellular())); connect(connmanManager,SIGNAL(servicesChanged(ConnmanMapList,QList<QDBusObjectPath>)), this, SLOT(updateServices(ConnmanMapList,QList<QDBusObjectPath>))); connect(connmanManager,SIGNAL(servicesReady(QStringList)),this,SLOT(servicesReady(QStringList))); connect(connmanManager,SIGNAL(scanFinished()),this,SLOT(finishedScan())); foreach (const QString &servPath, connmanManager->getServices()) { addServiceConfiguration(servPath); } Q_EMIT updateCompleted(); }
DeviceDiscoveryDialog::DeviceDiscoveryDialog(QWidget *parent) : QDialog(parent), localDevice(new QBluetoothLocalDevice), ui(new Ui_DeviceDiscovery) { ui->setupUi(this); /* * In case of multiple Bluetooth adapters it is possible to set adapter * which will be used. Example code: * * QBluetoothAddress address("XX:XX:XX:XX:XX:XX"); * discoveryAgent = new QBluetoothDeviceDiscoveryAgent(address); * **/ discoveryAgent = new QBluetoothDeviceDiscoveryAgent(); connect(ui->inquiryType, SIGNAL(toggled(bool)), this, SLOT(setGeneralUnlimited(bool))); connect(ui->scan, SIGNAL(clicked()), this, SLOT(startScan())); connect(discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), this, SLOT(addDevice(QBluetoothDeviceInfo))); connect(discoveryAgent, SIGNAL(finished()), this, SLOT(scanFinished())); connect(ui->list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemActivated(QListWidgetItem*))); connect(localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)), this, SLOT(hostModeStateChanged(QBluetoothLocalDevice::HostMode))); hostModeStateChanged(localDevice->hostMode()); // add context menu for devices to be able to pair device ui->list->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->list, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(displayPairingMenu(QPoint))); connect(localDevice, SIGNAL(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing)) , this, SLOT(pairingDone(QBluetoothAddress,QBluetoothLocalDevice::Pairing))); }
//-------------------------------------------------------------------------- ScanView::ScanView(Scanner* scanner, QWidget* parent) : QSplitter(parent), scanner(scanner), library(new Library(this)), metaForm(new MetaDataForm(this)), imageViewer(new ImageViewer(this)) { // Connect signals for scan progress connect(scanner, SIGNAL(started()), this, SLOT(scanStarted())); connect(scanner, SIGNAL(finished(Scanner::ScanResult)), this, SLOT(scanFinished(Scanner::ScanResult))); createButtons(); QHBoxLayout* buttonsLayout = new QHBoxLayout; buttonsLayout->addWidget(scanPreviewButton); buttonsLayout->addWidget(cancelButton); buttonsLayout->addWidget(acceptScanButton); buttonsLayout->addWidget(rejectScanButton); buttonsLayout->addWidget(resetButton); // Connect signals for form states connect(metaForm, SIGNAL(isEmpty(bool)), this, SLOT(formIsEmpty(bool))); connect(metaForm, SIGNAL(isValid(bool)), scanPreviewButton, SLOT(setEnabled(bool))); QVBoxLayout* leftLayout = new QVBoxLayout; leftLayout->addWidget(metaForm); leftLayout->addLayout(buttonsLayout); QWidget* leftWidget = new QWidget(this); leftWidget->setLayout(leftLayout); addWidget(leftWidget); addWidget(imageViewer); setStretchFactor(1, 2); // Give more weight to the viewer }
LibraryScanner::LibraryScanner(QWidget* pParentWidget, TrackCollection* collection) : m_pCollection(collection), m_libraryHashDao(m_database), m_cueDao(m_database), m_playlistDao(m_database), m_crateDao(m_database), m_directoryDao(m_database), m_analysisDao(m_database, collection->getConfig()), m_trackDao(m_database, m_cueDao, m_playlistDao, m_crateDao, m_analysisDao, m_libraryHashDao, collection->getConfig()) { // Don't initialize m_database here, we need to do it in run() so the DB // conn is in the right thread. qDebug() << "Starting LibraryScanner thread."; // Move LibraryScanner to its own thread so that our signals/slots will // queue to our event loop. moveToThread(this); m_pool.moveToThread(this); unsigned static id = 0; // the id of this LibraryScanner, for debugging purposes setObjectName(QString("LibraryScanner %1").arg(++id)); m_pool.setMaxThreadCount(kScannerThreadPoolSize); // Listen to signals from our public methods (invoked by other threads) and // connect them to our slots to run the command on the scanner thread. connect(this, SIGNAL(startScan()), this, SLOT(slotStartScan())); // Force the GUI thread's TrackInfoObject cache to be cleared when a library // scan is finished, because we might have modified the database directly // when we detected moved files, and the TIOs corresponding to the moved // files would then have the wrong track location. connect(this, SIGNAL(scanFinished()), &(collection->getTrackDAO()), SLOT(clearCache())); connect(this, SIGNAL(trackAdded(TrackPointer)), &(collection->getTrackDAO()), SLOT(databaseTrackAdded(TrackPointer))); connect(this, SIGNAL(tracksMoved(QSet<int>, QSet<int>)), &(collection->getTrackDAO()), SLOT(databaseTracksMoved(QSet<int>, QSet<int>))); connect(this, SIGNAL(tracksChanged(QSet<int>)), &(collection->getTrackDAO()), SLOT(databaseTracksChanged(QSet<int>))); // Parented to pParentWidget so we don't need to delete it. LibraryScannerDlg* pProgress = new LibraryScannerDlg(pParentWidget); connect(this, SIGNAL(progressLoading(QString)), pProgress, SLOT(slotUpdate(QString))); connect(this, SIGNAL(progressHashing(QString)), pProgress, SLOT(slotUpdate(QString))); connect(this, SIGNAL(scanStarted()), pProgress, SLOT(slotScanStarted())); connect(this, SIGNAL(scanFinished()), pProgress, SLOT(slotScanFinished())); connect(pProgress, SIGNAL(scanCancelled()), this, SLOT(cancel())); connect(&m_trackDao, SIGNAL(progressVerifyTracksOutside(QString)), pProgress, SLOT(slotUpdate(QString))); connect(&m_trackDao, SIGNAL(progressCoverArt(QString)), pProgress, SLOT(slotUpdateCover(QString))); start(); }
Library::Library( QObject* parent, UserSettingsPointer pConfig, mixxx::DbConnectionPoolPtr pDbConnectionPool, PlayerManagerInterface* pPlayerManager, RecordingManager* pRecordingManager) : m_pConfig(pConfig), m_pDbConnectionPool(pDbConnectionPool), m_pSidebarModel(new SidebarModel(parent)), m_pTrackCollection(new TrackCollection(pConfig)), m_pLibraryControl(new LibraryControl(this)), m_pMixxxLibraryFeature(nullptr), m_pPlaylistFeature(nullptr), m_pCrateFeature(nullptr), m_pAnalysisFeature(nullptr), m_scanner(pDbConnectionPool, m_pTrackCollection, pConfig) { QSqlDatabase dbConnection = mixxx::DbConnectionPooled(m_pDbConnectionPool); // TODO(XXX): Add a checkbox in the library preferences for checking // and repairing the database on the next restart of the application. if (pConfig->getValue(kConfigKeyRepairDatabaseOnNextRestart, false)) { kLogger.info() << "Checking and repairing database (if necessary)"; m_pTrackCollection->repairDatabase(dbConnection); // Reset config value pConfig->setValue(kConfigKeyRepairDatabaseOnNextRestart, false); } kLogger.info() << "Connecting database"; m_pTrackCollection->connectDatabase(dbConnection); qRegisterMetaType<Library::RemovalType>("Library::RemovalType"); m_pKeyNotation.reset(new ControlObject(ConfigKey(kConfigGroup, "key_notation"))); connect(&m_scanner, SIGNAL(scanStarted()), this, SIGNAL(scanStarted())); connect(&m_scanner, SIGNAL(scanFinished()), this, SIGNAL(scanFinished())); // Refresh the library models when the library (re)scan is finished. connect(&m_scanner, SIGNAL(scanFinished()), this, SLOT(slotRefreshLibraryModels())); // TODO(rryan) -- turn this construction / adding of features into a static // method or something -- CreateDefaultLibrary m_pMixxxLibraryFeature = new MixxxLibraryFeature(this, m_pTrackCollection,m_pConfig); addFeature(m_pMixxxLibraryFeature); addFeature(new AutoDJFeature(this, pConfig, pPlayerManager, m_pTrackCollection)); m_pPlaylistFeature = new PlaylistFeature(this, m_pTrackCollection, m_pConfig); addFeature(m_pPlaylistFeature); m_pCrateFeature = new CrateFeature(this, m_pTrackCollection, m_pConfig); addFeature(m_pCrateFeature); BrowseFeature* browseFeature = new BrowseFeature( this, pConfig, m_pTrackCollection, pRecordingManager); connect(browseFeature, SIGNAL(scanLibrary()), &m_scanner, SLOT(scan())); connect(&m_scanner, SIGNAL(scanStarted()), browseFeature, SLOT(slotLibraryScanStarted())); connect(&m_scanner, SIGNAL(scanFinished()), browseFeature, SLOT(slotLibraryScanFinished())); addFeature(browseFeature); addFeature(new RecordingFeature(this, pConfig, m_pTrackCollection, pRecordingManager)); addFeature(new SetlogFeature(this, pConfig, m_pTrackCollection)); m_pAnalysisFeature = new AnalysisFeature(this, pConfig, m_pTrackCollection); connect(m_pPlaylistFeature, SIGNAL(analyzeTracks(QList<TrackId>)), m_pAnalysisFeature, SLOT(analyzeTracks(QList<TrackId>))); connect(m_pCrateFeature, SIGNAL(analyzeTracks(QList<TrackId>)), m_pAnalysisFeature, SLOT(analyzeTracks(QList<TrackId>))); addFeature(m_pAnalysisFeature); //iTunes and Rhythmbox should be last until we no longer have an obnoxious //messagebox popup when you select them. (This forces you to reach for your //mouse or keyboard if you're using MIDI control and you scroll through them...) if (RhythmboxFeature::isSupported() && pConfig->getValue(ConfigKey(kConfigGroup,"ShowRhythmboxLibrary"), true)) { addFeature(new RhythmboxFeature(this, m_pTrackCollection)); } if (pConfig->getValue(ConfigKey(kConfigGroup,"ShowBansheeLibrary"), true)) { BansheeFeature::prepareDbPath(pConfig); if (BansheeFeature::isSupported()) { addFeature(new BansheeFeature(this, m_pTrackCollection, pConfig)); } } if (ITunesFeature::isSupported() && pConfig->getValue(ConfigKey(kConfigGroup,"ShowITunesLibrary"), true)) { addFeature(new ITunesFeature(this, m_pTrackCollection)); } if (TraktorFeature::isSupported() && pConfig->getValue(ConfigKey(kConfigGroup,"ShowTraktorLibrary"), true)) { addFeature(new TraktorFeature(this, m_pTrackCollection)); } // On startup we need to check if all of the user's library folders are // accessible to us. If the user is using a database from <1.12.0 with // sandboxing then we will need them to give us permission. QStringList directories = m_pTrackCollection->getDirectoryDAO().getDirs(); qDebug() << "Checking for access to user's library directories:"; foreach (QString directoryPath, directories) { QFileInfo directory(directoryPath); bool hasAccess = Sandbox::askForAccess(directory.canonicalFilePath()); qDebug() << "Checking for access to" << directoryPath << ":" << hasAccess; }
void ScanProc::run() { while (!m_webcam->read(m_image)) { msleep(100); } if (mesh == NULL || gla == NULL) { Q_ASSERT(false); return; } mesh->Clear(); Edit3DScanPlugin::turntable->enable(); Edit3DScanPlugin::turntable->setDirection(FS_DIRECTION_CCW); double degreesPerStep = 360.0f/200.0f/16.0f; //the size of a microstep degreesPerStep = 10; // turn faster for test for(double i = 0; i < 360; i += degreesPerStep) { // turn on laser Edit3DScanPlugin::arduino->writeChar(MC_TURN_LASER_ON); msleep(LASER_ON_DELAY); // get one image m_webcam->read(m_image); Mat matLaserOn = m_image; #ifdef WIN32 //matLaserOn = imread("input_laser_on.jpg", CV_LOAD_IMAGE_COLOR); #else //matLaserOn = imread("/Users/justin/MeshLabSrc/laserOn.jpg"); #endif // turn off laser Edit3DScanPlugin::arduino->writeChar(MC_TURN_LASER_OFF); // delay msleep(LASER_OFF_DELAY); // get one image m_webcam->read(m_image); Mat matLaserOff = m_image; #ifdef WIN32 //matLaserOff = imread("input_laser_off.jpg", CV_LOAD_IMAGE_COLOR); #else //matLaserOff = imread("/Users/justin/MeshLabSrc/laserOff.jpg"); #endif //Mat matLaserLine = DetectLaser(matLaserOn, matLaserOff); Mat matLaserLine = DetectLaser2(matLaserOn, matLaserOff); MapLaserPointToGlobalPoint(matLaserLine, matLaserOff); //turn turntable a step Edit3DScanPlugin::turntable->turnNumberOfDegrees(degreesPerStep); if (fstop) { break; } } Edit3DScanPlugin::turntable->disable(); emit scanFinished(); }
void QWifiManagerPrivateUnix::startScan() { if (wirelessDevice != NULL) { updateAccessPoints(); return; } QDBusInterface networkManager(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, QDBusConnection::systemBus()); if (!networkManager.isValid()) { emit scanFinished(QWifiManager::ERROR_NO_NM); return; } QDBusReply<QList<QDBusObjectPath> > devices = networkManager.call( "GetDevices"); if (!devices.isValid()) { emit scanFinished(QWifiManager::ERROR); return; } bool foundWifi = false; foreach (const QDBusObjectPath& connection, devices.value()) { //qDebug() << connection.path(); QDBusInterface device(NM_DBUS_SERVICE, connection.path(), NM_DBUS_INTERFACE_DEVICE, QDBusConnection::systemBus()); if (!device.isValid()) { emit scanFinished(QWifiManager::ERROR); return; } QVariant deviceType = device.property("DeviceType"); if (!deviceType.isValid()) { emit scanFinished(QWifiManager::ERROR); return; } //qDebug() << deviceType.toUInt(); if (deviceType.toUInt() == NM_DEVICE_TYPE_WIFI) { foundWifi = true; QVariant deviceState = device.property("State"); if (!deviceState.isValid()) { emit scanFinished(QWifiManager::ERROR); return; } if (deviceState.toUInt() <= NM_DEVICE_STATE_UNAVAILABLE) continue; // we are only interested in enabled wifi devices wirelessDevice = new QDBusInterface(NM_DBUS_SERVICE, connection.path(), NM_DBUS_INTERFACE_DEVICE_WIRELESS, QDBusConnection::systemBus()); if (!wirelessDevice->isValid()) { emit scanFinished(QWifiManager::ERROR); return; } QDBusConnection::systemBus().connect(NM_DBUS_SERVICE, connection.path(), NM_DBUS_INTERFACE_DEVICE_WIRELESS, "AccessPointAdded", this, SLOT(updateAccessPoints())); QDBusConnection::systemBus().connect(NM_DBUS_SERVICE, connection.path(), NM_DBUS_INTERFACE_DEVICE_WIRELESS, "AccessPointRemoved", this, SLOT(updateAccessPoints())); QDBusConnection::systemBus().connect(NM_DBUS_SERVICE, connection.path(), NM_DBUS_INTERFACE_DEVICE_WIRELESS, "PropertiesChanged", this, SLOT(updateAccessPoints())); QDBusReply<QList<QDBusObjectPath> > accessPoints = wirelessDevice->call("GetAccessPoints"); if (!accessPoints.isValid()) { emit scanFinished(QWifiManager::ERROR); return; } clearPreviousScanResults(); foreach (const QDBusObjectPath& connection, accessPoints.value()) { //qDebug() << connection.path(); QDBusInterface accessPoint(NM_DBUS_SERVICE, connection.path(), NM_DBUS_INTERFACE_ACCESS_POINT, QDBusConnection::systemBus()); QVariant mac = accessPoint.property("HwAddress"); QVariant ssid = accessPoint.property("Ssid"); QVariant frequency = accessPoint.property("Frequency"); QVariant strengh = accessPoint.property("Strength"); QVariant capabilitiesWPA = accessPoint.property("WpaFlags"); QVariant capabilitiesRSN = accessPoint.property("RsnFlags"); QVariant flags = accessPoint.property("Flags"); if (!ssid.isValid() || !mac.isValid() || !frequency.isValid() || !strengh.isValid() || !capabilitiesRSN.isValid() || !capabilitiesWPA.isValid() || !flags.isValid() ) { emit scanFinished(QWifiManager::ERROR); return; } unsigned int capabilities = capabilitiesWPA.toUInt() | capabilitiesRSN.toUInt() | flags.toUInt(); QString enc; if (capabilities & (NM_802_11_AP_SEC_PAIR_TKIP | NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_TKIP | NM_802_11_AP_SEC_GROUP_CCMP | NM_802_11_AP_SEC_KEY_MGMT_PSK | NM_802_11_AP_SEC_KEY_MGMT_802_1X)) enc = QWifiManager::PSK; else if (capabilities & (NM_802_11_AP_SEC_PAIR_WEP40 | NM_802_11_AP_SEC_PAIR_WEP104 | NM_802_11_AP_SEC_GROUP_WEP40 | NM_802_11_AP_SEC_GROUP_WEP104)) enc = QWifiManager::WEP; else enc = QWifiManager::OPEN; //qDebug() << ssid.toString() << " " << mac.toString() << " " // << frequency.toString() << "Mhz Strength:" // << strengh.toUInt(); scanResults.append( new QScanResult(ssid.toString(), mac.toString(), enc, frequency.toInt(), strengh.toInt())); } emit scanFinished(QWifiManager::SCAN_OK); return; } }
void Scanner_Master::scanIsFinished() { emit scanFinished(); }