/** * setInput - set the name of the expected video file * * @param fileName - the name of the video file * * @return True if success. False otherwise */ bool VideoProcessor::setInput(const std::string &fileName) { fnumber = 0; tempFile = fileName; // In case a resource was already // associated with the VideoCapture instance if (isOpened()){ capture.release(); } // Open the video file if(capture.open(fileName)){ // read parameters length = capture.get(CV_CAP_PROP_FRAME_COUNT); rate = getFrameRate(); cv::Mat input; // show first frame getNextFrame(input); emit showFrame(input); emit updateBtn(); return true; } else { return false; } }
void MainWindow::onCompareEditChanged() { compareList.clear(); QStringList lines = ui->compareEdit->toPlainText().split("\n"); bool valid = true; for(auto line:lines) { line = line.trimmed(); if(line.isEmpty()) continue; QFileInfo check(line); if(!check.isDir()) { valid = false; this->statusBar()->showMessage("对比目录错误:" + line); } else { compareList.push_back(line); } } if(valid) this->statusBar()->clearMessage(); else { compareList.clear(); } updateBtn(); }
void MainWindow::onWatchEditChanged() { watchList.clear(); QTextEdit* watchEdit = ui->watchEdit; QStringList lines = watchEdit->toPlainText().split("\n"); bool valid = true; QStringList validList; QString str; for(auto line:lines) { line = line.trimmed(); QFileInfo check(line); if(check.isFile() || check.isDir()) validList.push_back(line); else { valid = false; this->statusBar()->showMessage("监视路径错误:" + line); } } if(valid) { this->statusBar()->clearMessage(); watchList.swap(validList); } updateBtn(); }
bool HelloWorld::init() { if ( !CCLayerColor::initWithColor(ccc4(255, 255, 255, 255)) ) { return false; } CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); CCSprite* bg = CCSprite::create("bg.png"); bg->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2)); this->addChild(bg, 0, 0); CCMenuItemImage *pCloseItem = CCMenuItemImage::create( "CloseNormal.png", "CloseSelected.png", this, menu_selector(HelloWorld::menuCloseCallback)); pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 , origin.y + pCloseItem->getContentSize().height/2)); CCMenuItemFont* sBtn = CCMenuItemFont::create("", this, menu_selector(HelloWorld::btnCB)); sBtn->setTag(SBTNTAG); sBtn->setAnchorPoint(CCPointZero); sBtn->setPosition(50, 200); sBtn->setColor(ccRED); CCMenuItemFont* rbtn = CCMenuItemFont::create("", this, menu_selector(HelloWorld::btnCB)); rbtn->setTag(RTBTNTAG); rbtn->setAnchorPoint(CCPointZero); rbtn->setPosition(50, 300); rbtn->setColor(ccGREEN); // create menu, it's an autorelease object pMenu = CCMenu::create(pCloseItem, sBtn, rbtn, NULL); pMenu->setPosition(CCPointZero); this->addChild(pMenu, 1); // show filter node this->setAnchorPoint(CCPointZero); fnode = GaussianBlur::screenBlurNodeInstance(); fnode->reset(this); this->addChild(fnode); updateBtn(SBTNTAG); updateBtn(RTBTNTAG); return true; }
void EEPROM_test::doTest() { emit enableBtn(btnName, false); emit updateBtn(btnName, YELLOW_XBTN); emit updateText(tr("EEPROM testing:Start test now..")); QEventLoop eventloop; QTimer::singleShot(1, &eventloop, SLOT(quit())); eventloop.exec(); //writeLog("[START COM1&COM3 TEST]"); /* if(openCOM1COM3()) { emit updateBtn(UART1_BTN, RED_XBTN); emit updateText(tr("COM1 testing:port open fail..")); writeLog(tr("COM1 testing:port open fail..")); emit enableBtn(UART1_BTN, true); result = -1; return; } if(COMRxTxTest()) { result = -1; ::close(fd1); ::close(fd2); emit updateBtn(UART1_BTN, RED_XBTN); emit enableBtn(UART1_BTN, true); return; } */ if (1) { Sleep(1000); emit updateBtn(btnName, GREEN_XBTN); } //emit updateText(tr("COM1 testing:RX/TX Test PASS!!")); //writeLog(tr("COM1 testing:RX/TX Test PASS!!")); //::close(fd1); //::close(fd2); emit enableBtn(btnName, true); }
void UpdateHandler::updateCheckResult() { if(!m_progress.isNull()) m_progress->deleteLater(); int res = m_watcher->result(); if(m_autoCheck && (res == RES_CHECK_FAILED || res == RES_NO_UPDATE)) { deleteLater(); return; } static const QString texts[] = { tr("Update check has failed!"), tr("No update available"), tr("New update for Lorris is available") }; switch(res) { case RES_CHECK_FAILED: { sWorkTabMgr.printToAllStatusBars(texts[res]); ToolTipWarn *w = new ToolTipWarn(texts[res], NULL, NULL, 4000, ":/icons/warning"); w->toRightBottom(); deleteLater(); break; } case RES_NO_UPDATE: { sWorkTabMgr.printToAllStatusBars(texts[res]); ToolTipWarn *w = new ToolTipWarn(texts[res], NULL, NULL, 3000, ":/actions/info"); w->toRightBottom(); deleteLater(); break; } case RES_UPDATE_AVAILABLE: { sWorkTabMgr.printToAllStatusBars(texts[res]); ToolTipWarn *w = new ToolTipWarn(texts[res], NULL, NULL, 30000, ":/actions/update"); QPushButton *btn = new QPushButton(tr("Download")); w->setButton(btn); w->toRightBottom(); connect(btn, SIGNAL(clicked()), this, SLOT(updateBtn())); connect(btn, SIGNAL(clicked()), w, SLOT(deleteLater())); break; } default: { sWorkTabMgr.printToAllStatusBars(""); deleteLater(); break; } } }
void HelloWorld::btnCB(CCObject* pSender) { const int tag = ((CCNode*)pSender)->getTag(); if (tag == RTBTNTAG) { if (fnode && fnode->isVisible()) { fnode->realtime(!fnode->isRealTime()); } } else if (tag == SBTNTAG) { CCSprite* bg = (CCSprite*)this->getChildByTag(0); if (fnode) { // remove from view (中文:调用此方法来删除显示在模糊节点上的节点, 并清除自己) fnode->cleanFromWorld(); fnode = NULL; bg->stopAllActions(); } else { fnode = GaussianBlur::screenBlurNodeInstance(); CCSprite* a = CCSprite::create("a.png"); a->setPosition(ccp(400, 240)); fnode->addChild(a); fnode->reset(this); fnode->show(); // or you may use this like code(中文:你也许更喜欢用类似的显示方式) //CCDirector::sharedDirector()->getRunningScene()->addChild(fnode); // run a action to show realtime update blur effect(中文:显示一个动画,来凸显实时模糊的功能) bg->setPosition(ccpSub(bg->getPosition(), ccp(200, 0))); bg->runAction(CCRepeatForever::create( CCSequence::createWithTwoActions( CCMoveBy::create(1.0f, ccp(400, 0)), CCMoveBy::create(1.0f, ccp(-400, 0)) ))); } } updateBtn(RTBTNTAG); updateBtn(SBTNTAG); }
AddQuoteDialog::AddQuoteDialog(bool isBilling, int idCustomer, int id, bool copy, QWidget *parent) : QDialog(parent), _quote(0), ui(new Ui::AddQuoteDialog), _copy(copy), _idCustomer(idCustomer) { ui->setupUi(this); Gui::Utils::WindowSettings::setPositionToCenter(*this); ui->wdgContributories = new Gui::Widgets::ContributoriesWidget( QSharedPointer<Customer>(new Customer(idCustomer)), this); connect(ui->wdgContributories, SIGNAL(contributoryChanged()), this, SLOT(updateBtn())); if (id != 0) { _quote = new Billing(id); fillFields(); if (copy) { setQuoteIdNumber(0,isBilling); fillQuoteBillingCopy(isBilling); ui->dateEditQuote->setDate(QDate::currentDate()); } else { ui->btnDocChange->hide(); setWindowTitle((isBilling ? "Modifier la facture " : "Modifier le devis ")+ QString::number(getNumber())+ " de " + (Customer(idCustomer).getCompany())); } } else { _quote = new Billing(); setQuoteIdNumber(id, isBilling); ui->dateEditQuote->setDate(QDate::currentDate()); ui->btnDocChange->hide(); fillQuoteBilling(isBilling); } _quote->setIsBilling(isBilling); ui->_2->addWidget(ui->wdgContributories, 5, 0, 1, 2); emit ui->leQuoteTitle->textChanged(_quote->getTitle()); ((Gui::Widgets::ContributoriesWidget*)ui->wdgContributories)->updateUi(); }
/** * playIt - play the frames of the sequence * */ void VideoProcessor::playIt() { // current frame cv::Mat input; // if no capture device has been set if (!isOpened()) return; // is playing stop = false; // update buttons emit updateBtn(); while (!isStop()) { // read next frame if any if (!getNextFrame(input)) break; curPos = capture.get(CV_CAP_PROP_POS_FRAMES); // display input frame emit showFrame(input); // update the progress bar emit updateProgressBar(); // introduce a delay emit sleep(delay); } if (!isStop()){ emit revert(); } }
/** * pauseIt - pause playing * */ void VideoProcessor::pauseIt() { stop = true; emit updateBtn(); }
/**************************************************************************** * MenuLanguageSelect ***************************************************************************/ int MenuLanguageSelect() { int cnt = 0; int ret = 0, choice = 0; int scrollon; int returnhere = 0; GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume); // because destroy GuiSound must wait while sound playing is finished, we use a global sound if(!btnClick2) btnClick2=new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume); // GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume); char imgPath[100]; snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); GuiImageData btnOutline(imgPath, button_dialogue_box_png); snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); GuiImageData settingsbg(imgPath, settings_background_png); GuiTrigger trigA; trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); GuiTrigger trigB; trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); char fullpath[100]; int countfiles = GetAllDirFiles(Settings.languagefiles_path); if (!strcmp("", Settings.languagefiles_path)) { sprintf(fullpath, "%s", tr("Standard")); } else { sprintf(fullpath, "%s", Settings.languagefiles_path); } GuiText titleTxt(fullpath, 24, (GXColor) {0, 0, 0, 255}); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); titleTxt.SetPosition(0,0); GuiButton pathBtn(300, 50); pathBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); pathBtn.SetPosition(0,28); pathBtn.SetLabel(&titleTxt); pathBtn.SetSoundOver(&btnSoundOver); pathBtn.SetSoundClick(btnClick2); pathBtn.SetTrigger(&trigA); pathBtn.SetEffectGrow(); GuiImage oggmenubackground(&settingsbg); oggmenubackground.SetAlignment(ALIGN_LEFT, ALIGN_TOP); oggmenubackground.SetPosition(0, 0); GuiText backBtnTxt(tr("Back") , 22, THEME.prompttext); backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); GuiImage backBtnImg(&btnOutline); if (Settings.wsprompt == yes) { backBtnTxt.SetWidescreen(CFG.widescreen); backBtnImg.SetWidescreen(CFG.widescreen); } GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); backBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); backBtn.SetPosition(-190, 400); backBtn.SetLabel(&backBtnTxt); backBtn.SetImage(&backBtnImg); backBtn.SetSoundOver(&btnSoundOver); backBtn.SetSoundClick(btnClick2); backBtn.SetTrigger(&trigA); backBtn.SetTrigger(&trigB); backBtn.SetEffectGrow(); GuiText defaultBtnTxt(tr("Default") , 22, THEME.prompttext); defaultBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); GuiImage defaultBtnImg(&btnOutline); if (Settings.wsprompt == yes) { defaultBtnTxt.SetWidescreen(CFG.widescreen); defaultBtnImg.SetWidescreen(CFG.widescreen); } GuiButton defaultBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); defaultBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); defaultBtn.SetPosition(190, 400); defaultBtn.SetLabel(&defaultBtnTxt); defaultBtn.SetImage(&defaultBtnImg); defaultBtn.SetSoundOver(&btnSoundOver); defaultBtn.SetSoundClick(btnClick2); defaultBtn.SetTrigger(&trigA); defaultBtn.SetEffectGrow(); GuiText updateBtnTxt(tr("Update Files") , 22, THEME.prompttext); updateBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); GuiImage updateBtnImg(&btnOutline); if (Settings.wsprompt == yes) { updateBtnTxt.SetWidescreen(CFG.widescreen); updateBtnImg.SetWidescreen(CFG.widescreen); } GuiButton updateBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); updateBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); updateBtn.SetPosition(0, 400); updateBtn.SetLabel(&updateBtnTxt); updateBtn.SetImage(&updateBtnImg); updateBtn.SetSoundOver(&btnSoundOver); updateBtn.SetSoundClick(btnClick2); updateBtn.SetTrigger(&trigA); updateBtn.SetEffectGrow(); customOptionList options2(countfiles); for (cnt = 0; cnt < countfiles; cnt++) { char filename[64]; strlcpy(filename, GetFileName(cnt), sizeof(filename)); char *dot = strchr(filename, '.'); if (dot) *dot='\0'; options2.SetName(cnt, "%s", filename); options2.SetValue(cnt, NULL); } if (cnt < 9) { scrollon = 0; } else { scrollon = 1; } GuiCustomOptionBrowser optionBrowser4(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, scrollon, 10); optionBrowser4.SetPosition(0, 90); optionBrowser4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); HaltGui(); GuiWindow w(screenwidth, screenheight); w.Append(&oggmenubackground); w.Append(&pathBtn); w.Append(&backBtn); w.Append(&defaultBtn); w.Append(&updateBtn); w.Append(&optionBrowser4); mainWindow->Append(&w); w.SetEffect(EFFECT_FADE, 20); ResumeGui(); while (w.GetEffect()>0) usleep(50); while (!returnhere) { if (shutdown == 1) Sys_Shutdown(); else if (reset == 1) Sys_Reboot(); else if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); break; } else if (defaultBtn.GetState() == STATE_CLICKED) { choice = WindowPrompt(tr("Loading standard language."),0,tr("OK"), tr("Cancel")); if (choice == 1) { sprintf(Settings.language_path, "notset"); cfg_save_global(); gettextCleanUp(); HaltGui(); CFG_Load(); ResumeGui(); returnhere = 2; } defaultBtn.ResetState(); //optionBrowser4.SetFocus(1); // commented out to prevent crash } else if (updateBtn.GetState() == STATE_CLICKED) { choice = WindowPrompt(tr("Update all Language Files"),tr("Do you wish to update/download all language files?"),tr("OK"), tr("Cancel")); if (choice == 1) { bool network = true; if (!IsNetworkInit()) { network = NetworkInitPrompt(); } if (network) { const char URL[60] = "http://usbloader-gui.googlecode.com/svn/trunk/Languages/"; char fullURL[300]; FILE *pfile; URL_List LinkList(URL); int listsize = LinkList.GetURLCount(); subfoldercreate(Settings.languagefiles_path); for (int i = 0; i < listsize; i++) { ShowProgress(tr("Updating Language Files:"), 0, LinkList.GetURL(i), i, listsize-1); if (strcasecmp(".lang", strrchr(LinkList.GetURL(i), '.')) == 0) { snprintf(fullURL, sizeof(fullURL), "%s%s", URL, LinkList.GetURL(i)); struct block file = downloadfile(fullURL); if (file.data && file.size) { char filepath[300]; snprintf(filepath, sizeof(filepath), "%s%s", Settings.languagefiles_path, LinkList.GetURL(i)); pfile = fopen(filepath, "wb"); fwrite(file.data, 1, file.size, pfile); fclose(pfile); } free(file.data); } } ProgressStop(); returnhere = 1; break; } } updateBtn.ResetState(); //optionBrowser4.SetFocus(1); // commented out to prevent crash } else if (pathBtn.GetState() == STATE_CLICKED) { w.Remove(&optionBrowser4); w.Remove(&backBtn); w.Remove(&pathBtn); w.Remove(&defaultBtn); char entered[43] = ""; strlcpy(entered, Settings.languagefiles_path, sizeof(entered)); int result = OnScreenKeyboard(entered,43,0); w.Append(&optionBrowser4); w.Append(&pathBtn); w.Append(&backBtn); w.Append(&defaultBtn); if ( result == 1 ) { int len = (strlen(entered)-1); if (entered[len] !='/') strncat (entered, "/", 1); strlcpy(Settings.languagefiles_path, entered, sizeof(Settings.languagefiles_path)); WindowPrompt(tr("Languagepath changed."),0,tr("OK")); if (isInserted(bootDevice)) { cfg_save_global(); returnhere = 1; break; } else { WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); } } if (countfiles > 0) { optionBrowser4.SetFocus(1); } pathBtn.ResetState(); } ret = optionBrowser4.GetClickedOption(); if (ret>=0) { choice = WindowPrompt(tr("Do you want to change language?"), 0, tr("Yes"), tr("Cancel")); if (choice == 1) { if (isInserted(bootDevice)) { snprintf(Settings.language_path, sizeof(Settings.language_path), "%s%s", Settings.languagefiles_path, GetFileName(ret)); cfg_save_global(); if (!checkfile(Settings.language_path)) { sprintf(Settings.language_path, tr("not set")); WindowPrompt(tr("File not found."),tr("Loading standard language."),tr("OK")); } gettextCleanUp(); HaltGui(); CFG_Load(); ResumeGui(); returnhere = 2; break; } else { WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK"), 0,0,0,-1); } } optionBrowser4.SetFocus(1); } } w.SetEffect(EFFECT_FADE, -20); while (w.GetEffect()>0) usleep(50); HaltGui(); mainWindow->Remove(&w); ResumeGui(); return returnhere; }