void MainWindow::startCamera() { emit startWork(); }
void HardDiskDialog::switchToPane(paneTypes pane) { currentPane = pane; ui->progressThroughTransfer->setValue(pane); ui->DrivePane->setVisible(false); ui->TransferSelectionPane->setVisible(false); ui->TransferPane->setVisible(false); ui->EnvironmentPane->setVisible(false); ui->UserSetupPane->setVisible(false); ui->ReadyToTransferPane->setVisible(false); switch (pane) { case Drive: SetupDrivePane(); ui->DrivePane->setVisible(true); break; case TransferPC: SetupTransferPcPane(); ui->TransferSelectionPane->setVisible(true); break; case Transfer: SetupTransferPane(); ui->TransferPane->setVisible(true); break; case Environment: SetupEnvironmentPane(); ui->EnvironmentPane->setVisible(true); break; case User: SetupUserSetupPane(); ui->UserSetupPane->setVisible(true); break; case Confirm: ui->ReadyToTransferPane->setVisible(true); break; case DoTransfer: TransferProgress* p = new TransferProgress(this); p->showFullScreen(); QThread *thread = new QThread(); StorageMediaWorker *worker = new StorageMediaWorker(root, userMapping, transferSize); worker->moveToThread(thread); connect(thread, SIGNAL (started()), worker, SLOT (startWork())); connect(worker, SIGNAL (finished()), thread, SLOT (quit())); connect(worker, SIGNAL (finished()), worker, SLOT (deleteLater())); connect(thread, SIGNAL (finished()), thread, SLOT (deleteLater())); connect(worker, SIGNAL (progressChanged(qulonglong,qulonglong)), p, SLOT (setProgress(qulonglong,qulonglong))); connect(worker, SIGNAL (finished()), p, SLOT (finished())); thread->start(); } if (pane >= 1) { ui->backButton->setVisible(true); } else { ui->backButton->setVisible(false); } }
void run() { for (int i = 0; i < Manager::WorkerCount; ++i) { auto w = new Worker(); connect(this, SIGNAL(startWork()), w, SLOT(doWork())); connect(this, SIGNAL(stopWork()), w, SLOT(stop())); connect(this, SIGNAL(finished()), w, SLOT(deleteLater())); workers_ << w; } exec(); }
void MainWindow::startListenTcp(){ QThread *thr=new QThread(this); m_rpsvr =new RpSvrThread(); m_rpsvr->init(m_strTCPHost,m_strTCPPort.toInt(),"*"); m_rpsvr->moveToThread(thr); connect(thr,SIGNAL(started()),m_rpsvr,SLOT(startWork())); connect(m_rpsvr,SIGNAL(dataChanged()),this,SLOT(slUpdateTcpData())); connect(m_rpsvr,SIGNAL(connectionEstablished()),this,SLOT(slTcpEstablished())); connect(m_rpsvr,SIGNAL(connectionRefused(QString)),this,SLOT(slTcpRefused(QString))); thr->start(); }
void CellWorker::finishThread() { if (_workThread) { std::stringstream s ; s<<_workThread->get_id() ; _working = false ; startWork() ; _workThread->join() ; CELL_LOG(" **** work thread : %s finish **** ", s.str().c_str()) ; delete _workThread ; } }
// calls startWork, adds doWork() to queue void LLWorkerClass::addWork(S32 param, U32 priority) { mMutex.lock(); llassert_always(!(mWorkFlags & (WCF_WORKING|WCF_HAVE_WORK))); if (mRequestHandle != LLWorkerThread::nullHandle()) { llwarns << "LLWorkerClass attempt to add work with active worker!" << llendl; } #if _DEBUG // llinfos << "addWork: " << mWorkerClassName << " Param: " << param << llendl; #endif startWork(param); clearFlags(WCF_WORK_FINISHED|WCF_WORK_ABORTED); setFlags(WCF_HAVE_WORK); mRequestHandle = mWorkerThread->addWorkRequest(this, param, priority); mMutex.unlock(); }
void HardDiskDialog::SetupTransferPane() { ui->forwardButton->setEnabled(false); ui->backButton->setEnabled(false); ui->CountingFrame->setVisible(true); root = QDir(AllTransfersDir.path()); root.cd(ui->TransferList->selectedItems().at(0)->text()); QThread *thread = new QThread; CountWorker *worker = new CountWorker(root); worker->moveToThread(thread); connect(thread, SIGNAL (started()), worker, SLOT (startWork())); connect(worker, SIGNAL (finished(qulonglong, QTreeWidgetItem*)), thread, SLOT (quit())); connect(worker, SIGNAL (finished(qulonglong, QTreeWidgetItem*)), worker, SLOT (deleteLater())); connect(thread, SIGNAL (finished()), thread, SLOT (deleteLater())); connect(worker, SIGNAL (finished(qulonglong, QTreeWidgetItem*)), this, SLOT (countWorkerDone(qulonglong, QTreeWidgetItem*))); thread->start(); }
void MigratorBase::start() { if (mMigrationState == InProgress) { qWarning() << "already running"; return; } if (!canStart()) { Q_EMIT message(Error, i18n("Failed to start migration because migrator is not ready")); Q_EMIT stoppedProcessing(); return; } //TODO acquire dbus lock logMessage(Info, displayName()); Q_EMIT message(Info, i18n("Starting migration...")); setMigrationState(InProgress); setProgress(0); startWork(); }
bool MightyTCPEventSelectServer::Create(const unsigned short & usPort) { m_ListenPort=usPort; m_ListenSock = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); sockaddr_in sin; sin.sin_family = AF_INET; sin.sin_port = htons(usPort); sin.sin_addr.S_un.S_addr = INADDR_ANY; if(::bind(m_ListenSock, (sockaddr*)&sin, sizeof(sin)) == SOCKET_ERROR) { return -1; } ::listen(m_ListenSock,200); // 创建事件对象,并关联到监听的套节字 m_ListenEvent= ::WSACreateEvent(); ::WSAEventSelect(m_ListenSock,m_ListenEvent,FD_ACCEPT|FD_CLOSE); startWork(); }
void Scale::setupThread(QThread *scaleThread) { connect(scaleThread, SIGNAL(started()), this, SLOT(startWork())); run=false; }
bool MightyTCPCompletionPortServer::Create(const unsigned short & usPort) { /*if (!(P2PUtilTools::is2KOS())) { return false; }*/ m_ListenPort=usPort; m_ListenSock = ::WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED); SOCKADDR_IN si; si.sin_family = AF_INET; si.sin_port = ::ntohs(usPort); si.sin_addr.S_un.S_addr = INADDR_ANY; if(::bind(m_ListenSock, (sockaddr*)&si, sizeof(si)) == SOCKET_ERROR) { return false; } ::listen(m_ListenSock, 200); m_pListenObj= GetSocketObj(m_ListenSock); // 创建完成端口对象 m_hCompletionPort = ::CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0); // 加载扩展函数AcceptEx GUID GuidAcceptEx = WSAID_ACCEPTEX; DWORD dwBytes; ::WSAIoctl(m_ListenSock, SIO_GET_EXTENSION_FUNCTION_POINTER, &GuidAcceptEx, sizeof(GuidAcceptEx), &m_lpfnAcceptEx, sizeof(m_lpfnAcceptEx), &dwBytes, NULL, NULL); // 加载扩展函数GetAcceptExSockaddrs GUID GuidGetAcceptExSockaddrs = WSAID_GETACCEPTEXSOCKADDRS; ::WSAIoctl(m_ListenSock, SIO_GET_EXTENSION_FUNCTION_POINTER, &GuidGetAcceptExSockaddrs, sizeof(GuidGetAcceptExSockaddrs), &m_lpfnGetAcceptExSockaddrs, sizeof(m_lpfnGetAcceptExSockaddrs), &dwBytes, NULL, NULL ); // 将监听套节字关联到完成端口,注意,这里为它传递的CompletionKey为0 ::CreateIoCompletionPort((HANDLE)m_ListenSock, m_hCompletionPort, (DWORD)0, 0); // 注册FD_ACCEPT事件。 // 如果投递的AcceptEx I/O不够,线程会接收到FD_ACCEPT网络事件,说明应该投递更多的AcceptEx I/O WSAEventSelect(m_ListenSock, m_hAcceptEvent, FD_ACCEPT); startWork(); return 0; }
SWCreateAvatarInterface::SWCreateAvatarInterface(QApplication *parent) : m_uiCreateAvatar(new Ui::SWUI_WCreateAvatar), m_oTimer(new QBasicTimer), m_bGLFullScreen(false) { // set absolute path m_absolutePath = QDir::currentPath() + "/"; m_bWorkStarted = false; m_bResetKinect = false; // init rects m_oFaceRect.width = 0; m_oNoseRect.width = 0; // init main widget m_uiCreateAvatar->setupUi(this); this->setWindowTitle(QString("SWoOz : Create avatar")); this->setWindowIcon(QIcon(m_absolutePath + "../data/images/logos/icon_swooz_avatar.png")); // init opengl context QHBoxLayout *l_pGLContainerLayout = new QHBoxLayout(); l_pGLContainerLayout->layout()->setContentsMargins(0,0,0,0); m_pGLContainer = new QWidget(); QGLFormat l_glFormat; l_glFormat.setVersion( 4, 3 ); l_glFormat.setProfile(QGLFormat::CompatibilityProfile); l_glFormat.setSampleBuffers(true); QGLContext *l_glContext1 = new QGLContext(l_glFormat); QGLContext *l_glContext2 = new QGLContext(l_glFormat); // add widgets // display widgets // rgb m_WRGBDisplay = new SWDisplayImageWidget(this); m_uiCreateAvatar->hlRGB->addWidget(m_WRGBDisplay); // radial proj m_WRadialProjDisplay = new SWDisplayImageWidget(this, false, true); m_uiCreateAvatar->hlRadial->addWidget(m_WRadialProjDisplay); // face texture m_WFaceTextureDisplay = new SWDisplayImageWidget(this); m_uiCreateAvatar->hlFaceTexture->addWidget(m_WFaceTextureDisplay); // cloud gl widget m_WCloudGL = new SWGLCloudWidget(l_glContext1, this); m_WCloudGL->setCameraMode(SWQtCamera::TRACKBALL_CAMERA); // m_WCloudGL->setMaximumSize(640,480); m_uiCreateAvatar->hlCloud->addWidget(m_WCloudGL); // mesh gl widget m_WMeshGL = new SWGLMeshWidget(l_glContext2, this, m_absolutePath + "../data/shaders/createAvatarMesh.vert", m_absolutePath + "../data/shaders/createAvatarMesh.frag"); m_WMeshGL->setCameraMode(SWQtCamera::TRACKBALL_CAMERA); m_pGLContainer->setLayout(l_pGLContainerLayout); l_pGLContainerLayout->addWidget(m_WMeshGL); m_uiCreateAvatar->hlMesh->addWidget(m_pGLContainer); // init workers m_WCreateAvatar = new SWCreateAvatarWorker(&m_oKinectThread); // set connections // menu QObject::connect(m_uiCreateAvatar->actionExit, SIGNAL(triggered()), parent, SLOT(quit())); QObject::connect(m_uiCreateAvatar->actionOnline_documentation, SIGNAL(triggered()), this, SLOT(openOnlineDocumentation())); QObject::connect(m_uiCreateAvatar->actionSave_result, SIGNAL(triggered()), this, SLOT(saveMeshFile())); QObject::connect(m_uiCreateAvatar->actionAbout, SIGNAL(triggered()), this, SLOT(openAboutWindow())); // start work QObject::connect(m_uiCreateAvatar->pbStart, SIGNAL(clicked()), this, SLOT(startWork())); QObject::connect(this, SIGNAL(startWorkSignal()), m_WCreateAvatar, SLOT(doWork())); // stop work QObject::connect(m_uiCreateAvatar->pbStop, SIGNAL(clicked()), m_WCreateAvatar, SLOT(stopWork())); QObject::connect(this, SIGNAL(leaveProgram()), m_WCreateAvatar, SLOT(stopWork())); QObject::connect(m_WCreateAvatar, SIGNAL(stopWorkSignal()), SLOT(switchDetect())); // reconstruct QObject::connect(m_uiCreateAvatar->pbReconstruct, SIGNAL(clicked()), m_WCreateAvatar, SLOT(reconstruct())); // reset selected contours QObject::connect(m_uiCreateAvatar->pbResetSelectedContours, SIGNAL(clicked()), m_WCreateAvatar, SLOT(resetDeletedPointsRadialProj())); QObject::connect(m_uiCreateAvatar->pbResetSelectedContours, SIGNAL(clicked()), m_WRadialProjDisplay, SLOT(resetSelectedPoints())); // rectangles QObject::connect(m_WCreateAvatar, SIGNAL(sendFaceRect(cv::Rect*)), this, SLOT(updateFaceRectangle(cv::Rect*))); QObject::connect(m_WCreateAvatar, SIGNAL(sendNoseRect(cv::Rect*)), this, SLOT(updateNoseRectangle(cv::Rect*))); // stasmm points QObject::connect(m_WCreateAvatar, SIGNAL(sendStasmPoints(std::vector<cv::Point2i>)), this, SLOT(updateStasmPoints(std::vector<cv::Point2i>))); // cloud QObject::connect(m_WCreateAvatar, SIGNAL(sendCloud(swCloud::SWCloud*, bool)), m_WCloudGL, SLOT(setCloud(swCloud::SWCloud*, bool))); // mesh QObject::connect(m_WCreateAvatar, SIGNAL(sendMesh(swMesh::SWMesh*,bool)), m_WMeshGL, SLOT(setMesh(swMesh::SWMesh*,bool))); QObject::connect(m_uiCreateAvatar->pbSaveAvatar, SIGNAL(clicked()), this, SLOT(saveMeshFile())); QObject::connect(this, SIGNAL(saveMeshFileSignal(QString)), m_WCreateAvatar, SLOT(saveMeshFile(QString))); // ui QObject::connect(m_WCreateAvatar, SIGNAL(switchTab(int)),m_uiCreateAvatar->tw3D, SLOT(setCurrentIndex(int))); QObject::connect(m_WCreateAvatar, SIGNAL(enableInterfaceSignal()), this, SLOT(enableInterface())); // display QObject::connect(m_WCreateAvatar, SIGNAL(sendMat(cv::Mat*)), this, SLOT(updateRadialProjDisplay(cv::Mat*))); QObject::connect(m_WCreateAvatar, SIGNAL(sendTexture(cv::Mat*)), this, SLOT(udpdateTexture3DDisplay(cv::Mat*))); QObject::connect(m_WCreateAvatar, SIGNAL(sendTexture(cv::Mat*)), this, SLOT(updateFaceTextureDisplay(cv::Mat*))); // parameters // projection QObject::connect(m_uiCreateAvatar->sbWidth, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setRadialWidth(const int))); QObject::connect(m_uiCreateAvatar->sbHeight, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setRadialHeight(const int))); // QObject::connect(m_uiCreateAvatar->dsbRadius, SIGNAL(valueChanged(double)),m_WCreateAvatar, SLOT(setCylinderRadius(double))); QObject::connect(m_uiCreateAvatar->sbErode, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setErode(int))); QObject::connect(m_uiCreateAvatar->sbDilate, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setDilate(int))); QObject::connect(m_uiCreateAvatar->sbExpandValue,SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setExpandValue(int))); QObject::connect(m_uiCreateAvatar->sbExpandConnex,SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setExpandConnex(int))); QObject::connect(m_uiCreateAvatar->sbEraseValue,SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setEraseValue(int))); QObject::connect(m_uiCreateAvatar->sbEraseConnex,SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setEraseConnex(int))); // filter QObject::connect(m_uiCreateAvatar->sbColor, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setBilateralColor(const int))); QObject::connect(m_uiCreateAvatar->sbSpace, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setBilateralSpace(const int))); // QObject::connect(m_uiCreateAvatar->sbDiameter, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setBilateralDiameter(const int))); QObject::connect(m_uiCreateAvatar->sbClouds, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setCloudNumberValue(const int))); QObject::connect(m_uiCreateAvatar->cbBilateralFilter,SIGNAL(toggled(bool)) ,m_WCreateAvatar, SLOT(setUseBilateralFilter(bool))); // rgbd device QObject::connect(m_uiCreateAvatar->sbXOffset, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setCalibrationXValue(const int))); QObject::connect(m_uiCreateAvatar->sbYOffset, SIGNAL(valueChanged(int)), m_WCreateAvatar, SLOT(setCalibrationYValue(const int))); QObject::connect(m_uiCreateAvatar->dsbFaceDepth,SIGNAL(valueChanged(double)), m_WCloudGL, SLOT(setDepthRect(const double))); QObject::connect(m_uiCreateAvatar->dsbFaceDepth,SIGNAL(valueChanged(double)), m_WCreateAvatar, SLOT(setDepthCloud(const double))); // misc QObject::connect(m_uiCreateAvatar->cbSTASM, SIGNAL(toggled(bool)) ,m_WCreateAvatar, SLOT(setUseStasm(bool))); // display QObject::connect(m_uiCreateAvatar->cbDisplayLines, SIGNAL(toggled(bool)), m_WMeshGL, SLOT(setMeshLinesRender(const bool))); QObject::connect(m_uiCreateAvatar->cbApplyTexture, SIGNAL(toggled(bool)), m_WMeshGL, SLOT(applyTexture(bool))); // QObject::connect(m_uiCreateAvatar->dsbFOV, SIGNAL(valueChanged(double)),m_WMeshGL, SLOT(setFOV(const double))); // QObject::connect(m_uiCreateAvatar->dsbFOV, SIGNAL(valueChanged(double)),m_WCloudGL, SLOT(setFOV(const double))); QObject::connect(m_WCreateAvatar, SIGNAL(sendNumCloud(int)), this, SLOT(setNumCloud(const int))); // reset kinect QObject::connect(m_uiCreateAvatar->sbDeviceMode,SIGNAL(valueChanged(int)), this, SLOT(resetKinect(int))); QObject::connect(m_WCreateAvatar, SIGNAL(endResetKinect()), this, SLOT(releaseKinectMutex())); // others QObject::connect(m_WRadialProjDisplay, SIGNAL(clickPoint(QPoint, QSize, bool)), m_WCreateAvatar, SLOT(addPointToDeleteRadialProj(QPoint, QSize, bool))); // fullscreen QObject::connect(m_WMeshGL, SIGNAL(enableFullScreen()), this, SLOT(enableGLFullScreen())); QObject::connect(m_WMeshGL, SIGNAL(disableFullScreen()), this, SLOT(disableGLFullScreen())); // init worker parameters values // radial projection width / height m_WCreateAvatar->setRadialWidth(m_uiCreateAvatar->sbWidth->value()); m_WCreateAvatar->setRadialHeight(m_uiCreateAvatar->sbHeight->value()); // spatial filter m_WCreateAvatar->setBilateralColor(m_uiCreateAvatar->sbColor->value()); m_WCreateAvatar->setBilateralSpace(m_uiCreateAvatar->sbSpace->value()); m_WCreateAvatar->setBilateralDiameter(-1); // temporal filter m_WCreateAvatar->setCloudNumberValue(m_uiCreateAvatar->sbClouds->value()); // calibration m_WCreateAvatar->setCalibrationXValue(m_uiCreateAvatar->sbXOffset->value()); m_WCreateAvatar->setCalibrationYValue(m_uiCreateAvatar->sbYOffset->value()); // expand / erase m_WCreateAvatar->setExpandValue(m_uiCreateAvatar->sbExpandValue->value()); m_WCreateAvatar->setExpandConnex(m_uiCreateAvatar->sbExpandConnex->value()); m_WCreateAvatar->setEraseValue(m_uiCreateAvatar->sbEraseValue->value()); m_WCreateAvatar->setEraseConnex(m_uiCreateAvatar->sbEraseConnex->value()); // dilate / erode m_WCreateAvatar->setDilate(m_uiCreateAvatar->sbDilate->value()); m_WCreateAvatar->setErode(m_uiCreateAvatar->sbErode->value()); // stasm m_WCreateAvatar->setUseStasm(m_uiCreateAvatar->cbSTASM->isChecked()); // cloud m_WCloudGL->setDepthRect(m_uiCreateAvatar->dsbFaceDepth->value()); m_WCreateAvatar->setDepthCloud(m_uiCreateAvatar->dsbFaceDepth->value()); // desactive debug interface components // m_uiCreateAvatar->laPixelDiameter->setVisible(false); // m_uiCreateAvatar->sbDiameter->setVisible(false); // m_uiCreateAvatar->laCynlinderRadius->setVisible(false); // m_uiCreateAvatar->dsbRadius->setVisible(false); // m_uiCreateAvatar->laFOV->setVisible(false); // m_uiCreateAvatar->dsbFOV->setVisible(false); setStyleSheet("QGroupBox { padding: 10 0px 0 0px; color: blue; border: 1px solid gray; border-radius: 5px; margin-top: 1ex; /* leave space at the top for the title */}"); // init and start create avatar thread m_WCreateAvatar->moveToThread(&m_TCreateAvatar); m_TCreateAvatar.start(); // init face detection m_CFaceDetectPtr = SWFaceDetectionPtr(new swDetect::SWFaceDetection(cv::Size(80,80))); m_oLastRectFace.width = 0; // launch timer for updating the display widget m_oTimer->start(1000/30, this); }
void CellWorker::postWork(Cell* cell) { _cells.push(cell) ; startWork() ; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setCentralWidget(new QWidget); QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setContentsMargins(0,0,0,0); layout->setSpacing(0); layout->addWidget( ui.header = new Header( this ) ); connect( &Socket::sock(), SIGNAL(userLoggedIn(QString)), ui.header, SLOT(onUserConnected(QString)) ); connect( &Socket::sock(), SIGNAL(userLoggedOut()), ui.header, SLOT(onUserDisconnected()) ); connect( ui.header, SIGNAL(disconnectClicked()), &Socket::sock(), SLOT(logout()) ); // mettre obligatoirement ici pour corriger un petit bug d'affichage // /*temp refresh button*/ // QPushButton *refreshBtn = new QPushButton( "Refresh" ); // refreshBtn->setObjectName( "refreshBtn" ); // mainLayout->addWidget( refreshBtn ); // connect(refreshBtn, SIGNAL(clicked()), ui.header, SLOT( onRefreshClicked() ) ); QHBoxLayout* centralLayout = new QHBoxLayout( ); centralLayout->addWidget( ui.sideBar = new SideBar( this ) ); centralLayout->addWidget( ui.stackedWidget = new StackedWidget( this ) ); layout->addLayout( centralLayout ); connect(ui.sideBar, SIGNAL( currentChanged( int ) ), ui.stackedWidget, SLOT( setCurrentIndex( int ) ) ); connect(ui.sideBar, SIGNAL( currentChanged( int ) ), SLOT( loadViewData( int ) ) ); // LOG connect( &Socket::sock(), SIGNAL(clientEvent(int)), &Socket::sock(), SLOT(log(int)) ); // LIGHT BOX lightBox = new QLightBoxWidget(this); QHBoxLayout *mainLayout = new QHBoxLayout( lightBox ); QWidget *fm = new QWidget(); fm->setObjectName("connexionFrame"); mainLayout->addWidget( fm ); QGridLayout *lightBoxLayout = new QGridLayout( fm ); lightBoxLayout->setRowStretch(1, 1); settings = new QSettings("smoky.ini",QSettings::IniFormat); lightBoxLayout->addWidget( new QLabel( "IP du serveur" ), 0, 0); lightBoxLayout->addWidget( serverIpEdt = new QLineEdit(), 0, 1 ); serverIpEdt->setInputMask( "000.000.000.000; " ); serverIpEdt->setText( settings->value("serverIp").toString() ); serverIpEdt->setObjectName( "serverIpEdt" ); lightBoxLayout->addWidget( localhostCbx = new QCheckBox("localhost"), 1,1); localhostCbx->setObjectName( "localhostCbx" ); connect( localhostCbx, SIGNAL( stateChanged(int)), SLOT(onLocalhostCbx(int)) ); lightBoxLayout->addWidget( loginIndication = new QLabel(), 1, 0); loginIndication->setObjectName( "loginIndication" ); loginIndication->setText("<center><small>Placez votre visage<br>face à la caméra</small></center>"); lightBoxLayout->addWidget( loginAvatarLbl = new QLabel(""), 2, 0, 2, 1); loginAvatarLbl->setObjectName( "loginAvatarLbl" ); lightBoxLayout->addWidget( loginUserEdt = new QLineEdit(), 2, 1); loginUserEdt->setPlaceholderText("Nom d'utilisateur"); loginUserEdt->setObjectName( "loginUserEdt" ); lightBoxLayout->addWidget( loginPasswordEdt = new QLineEdit(), 3, 1); loginPasswordEdt->setObjectName( "loginPasswordEdt" ); loginPasswordEdt->setEchoMode( QLineEdit::Password ); loginPasswordEdt->setPlaceholderText("Mot de passe"); lightBoxLayout->addWidget( loginSubmitBtn = new QPushButton("Connexion"), 4, 1); loginSubmitBtn->setObjectName( "loginSubmitBtn" ); lightBoxLayout->addWidget( statLbl = new QLabel( "" ), 5,0, 1, 2 ); statLbl->setObjectName( "statLbl" ); lightBox->show(); Camera *cam = new Camera(); t = new QThread(); mTimer = new QTimer(); mTimer->setInterval(1000/24); connect(mTimer, SIGNAL(timeout()), cam, SLOT(queryFrame()) ); connect( this, SIGNAL(startWork()), cam, SLOT(openCamera()) ); connect( this, SIGNAL(startWork()), mTimer, SLOT(start()) ); connect( cam, SIGNAL(stopCamera()), mTimer, SLOT(stop()) ); connect( this, SIGNAL(stopWork()), cam, SLOT(closeCamera()) ); /*destruction*/ // connect( qApp, SIGNAL(aboutToQuit()),mTimer, SLOT(stop()) ); // connect( qApp, SIGNAL(aboutToQuit()),mTimer, SLOT(deleteLater()) ); // connect( qApp, SIGNAL(aboutToQuit()), cam, SLOT(closeCamera()) ); // connect( qApp, SIGNAL(aboutToQuit()), cam, SLOT(deleteLater()) ); connect(t, SIGNAL(finished()), cam, SLOT(deleteLater())); // connect(this, &Controller::operate, worker, &Worker::doWork); //connect( qApp, SIGNAL(aboutToQuit()), t, SLOT(quit()) ); // connect( t, SIGNAL(finished()), t, SLOT(deleteLater()) ); // user logged out connect( &Socket::sock(), SIGNAL(userLoggedOut()), SLOT(startCamera()) ); // user logged in connect( &Socket::sock(), SIGNAL(userLoggedIn(QString)), SLOT(stopCamera()) ); cam->moveToThread( t ); mTimer->moveToThread( t ); t->start( QThread::IdlePriority ); emit startWork(); connect(cam, SIGNAL(sendShot(QImage, QRect)), SLOT(onShotSent(QImage)) ); // receive shots connect( &Socket::sock(), SIGNAL(userLoggedIn(QString)), loginPasswordEdt, SLOT(clear()) ); connect( &Socket::sock(), SIGNAL(userLoggedIn(QString)), lightBox, SLOT(hide()) ); // rendre la page d'accueil connect( &Socket::sock(), SIGNAL(userLoggedOut()), SLOT(resetThings()) ); connect( &Socket::sock(), SIGNAL(invalidCred()), SLOT(onInvalidCred()) ); connect( loginSubmitBtn, SIGNAL(clicked()), SLOT(connectUser()) ); connect( &Socket::sock(), SIGNAL(connexionError(int)), SLOT(onConnexionError(int)) ); // move(QApplication::desktop()->screen()->rect().center() - this->rect().center()); /* QDesktopWidget desktop; QRect desktop_geometry = desktop.screenGeometry(); */ // resize( 780, 650 ); /*int x = desktop_geometry.width()/2 - width()/2; int y = desktop_geometry.height()/2 - height()/2; move( x, y );*/ // showMaximized(); }
void PomodoroTimerApplication::onStartPomodoro() { startWork(); updateSystemTrayIcon(); }