void QgsMessageBar::pushItem( QgsMessageBarItem *item ) { resetCountdown(); // avoid duplicated widget popWidget( item ); showItem( item ); }
void QgsMessageBar::pushItem( QgsMessageBarItem *item ) { resetCountdown(); // avoid duplicated widget popWidget( item ); showItem( item ); // Log all messages that are sent to the message bar into the message log so the // user can get them back easier. QString formattedTitle = QString( "%1 : %2" ).arg( item->title(), item->text() ); QgsMessageLog::MessageLevel level; switch ( item->level() ) { case QgsMessageBar::INFO: level = QgsMessageLog::INFO; break; case QgsMessageBar::WARNING: level = QgsMessageLog::WARNING; break; case QgsMessageBar::CRITICAL: level = QgsMessageLog::CRITICAL; break; default: level = QgsMessageLog::NONE; break; } QgsMessageLog::logMessage( formattedTitle, tr( "Messages" ), level ); }
void MpcImportWindow::createDialogContent() { ui->setupUi(dialog); //Signals connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint))); connect(ui->pushButtonAcquire, SIGNAL(clicked()), this, SLOT(acquireObjectData())); connect(ui->pushButtonAbortDownload, SIGNAL(clicked()), this, SLOT(abortDownload())); connect(ui->pushButtonAdd, SIGNAL(clicked()), this, SLOT(addObjects())); connect(ui->pushButtonDiscard, SIGNAL(clicked()), this, SLOT(discardObjects())); connect(ui->pushButtonBrowse, SIGNAL(clicked()), this, SLOT(selectFile())); connect(ui->comboBoxBookmarks, SIGNAL(currentIndexChanged(QString)), this, SLOT(bookmarkSelected(QString))); connect(ui->radioButtonFile, SIGNAL(toggled(bool)), ui->frameFile, SLOT(setVisible(bool))); connect(ui->radioButtonURL, SIGNAL(toggled(bool)), ui->frameURL, SLOT(setVisible(bool))); connect(ui->radioButtonAsteroids, SIGNAL(toggled(bool)), this, SLOT(switchImportType(bool))); connect(ui->radioButtonComets, SIGNAL(toggled(bool)), this, SLOT(switchImportType(bool))); connect(ui->pushButtonMarkAll, SIGNAL(clicked()), this, SLOT(markAll())); connect(ui->pushButtonMarkNone, SIGNAL(clicked()), this, SLOT(unmarkAll())); connect(ui->pushButtonSendQuery, SIGNAL(clicked()), this, SLOT(sendQuery())); connect(ui->lineEditQuery, SIGNAL(returnPressed()), this, SLOT(sendQuery())); connect(ui->pushButtonAbortQuery, SIGNAL(clicked()), this, SLOT(abortQuery())); connect(ui->lineEditQuery, SIGNAL(textEdited(QString)), this, SLOT(resetNotFound())); //connect(ui->lineEditQuery, SIGNAL(editingFinished()), this, SLOT(sendQuery())); connect(countdownTimer, SIGNAL(timeout()), this, SLOT(updateCountdown())); QSortFilterProxyModel * filterProxyModel = new QSortFilterProxyModel(this); filterProxyModel->setSourceModel(candidateObjectsModel); filterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); ui->listViewObjects->setModel(filterProxyModel); connect(ui->lineEditSearch, SIGNAL(textChanged(const QString&)), filterProxyModel, SLOT(setFilterFixedString(const QString&))); loadBookmarks(); updateTexts(); resetCountdown(); resetDialog(); }
void ChrsGrid::onTouchEnded(Touch*, Event*) { //如果能消除,那么清除已选文字 if (m_canCrush) { //首先暂停触摸 _eventDispatcher->pauseEventListenersForTarget(this); //对已选汉字盒子内的元素进行消除 goCrush(); //捕捉消除动作是否完成,完成后继续下一个动作 schedule(schedule_selector(ChrsGrid::onChrsCrushing), 0.02); } else { //如果不能,改变回背景颜色,其箭头也隐藏 for (auto &chr : m_SelectedChrs) { chr->getBg()->setTexture(chr->getNormalBG().c_str()); chr->hideArrow(); } //清空临时已选汉字集合 m_SelectedChrs.clear(); //更改主界面的letter label的显示 getGameScene()->setLetterLabel(getStringFromChrs(&m_SelectedChrs), false); } //开启倒计时捕捉,即开启提示功能 resetCountdown(); schedule(schedule_selector(ChrsGrid::onCountdownCallBack), 1); }
bool QgsMessageBar::popWidget() { if ( !mCurrentItem ) return false; resetCountdown(); QgsMessageBarItem *item = mCurrentItem; popItem( item ); return true; }
void QgsMessageBar::pushItem( QgsMessageBarItem *item ) { resetCountdown(); // avoid duplicated widget popWidget( item ); showItem( item ); // Log all messages that are sent to the message bar into the message log so the // user can get them back easier. QString formattedTitle = QStringLiteral( "%1 : %2" ).arg( item->title(), item->text() ); QgsMessageLog::logMessage( formattedTitle, tr( "Messages" ), item->level() ); }
void QgsMessageBar::updateCountdown() { if ( !mCountdownTimer->isActive() ) { resetCountdown(); return; } if ( mCountProgress->value() < 2 ) { popWidget(); } else { mCountProgress->setValue( mCountProgress->value() - 1 ); } }
void ChrsGrid::onCountdownCallBack(float dt) { //log ("count=%d", m_countdown); //如果倒计时结束,系统给予提示 if (m_countdown == 0) { unschedule(schedule_selector(ChrsGrid::onCountdownCallBack)); //重新启动倒计时 resetCountdown(); schedule(schedule_selector(ChrsGrid::onCountdownCallBack), 1); //系统演示消除步骤 showAnswer(); } m_countdown--; }
bool ChrsGrid::init(ValueMap level_info, int col, int row) { Node::init(); m_letter_info = level_info;//获取关卡配置信息 //设置棋盘的锚点和大小,锚点为中心 this->setContentSize(Size(col*GRID_WIDTH, row*GRID_WIDTH)); this->setAnchorPoint(Vec2(0.5, 0.5)); //绘制一个矩形,用以测试棋盘范围 auto drawnode = DrawNode::create(); drawnode->drawRect(Vec2(0, 0), Vec2(this->getContentSize().width, this->getContentSize().height), Color4F::RED); //addChild(drawnode); //棋盘底图 auto gridbg = ui::Scale9Sprite::create("grid_bg.png"); gridbg->setContentSize(Size(col * GRID_WIDTH + 10, row * GRID_WIDTH + 10)); gridbg->setPosition(this->getContentSize().width / 2, this->getContentSize().height / 2); addChild(gridbg, 0, 1000); //得到单词集合 m_Letters = level_info.at("letter").asValueVector(); //初始化汉字集合 initChrBox(); //生成布局 //根据行列初始化一个空的汉字盒子大小 m_row = row; m_col = col; m_canCrush = false; m_SelectedChrs.clear(); m_NewChrs.clear(); m_ChrsBox.resize(m_col); for (auto &vec : m_ChrsBox) { vec.resize(m_row); } //生成汉字字典树 createTrie(&chr_root, &m_Letters); //1.根据布局大小创建出汉字阵列 //2.布局坐标以左下角为原点,x右y上为正方向 for (int x = 0; x < m_col; x++) { for (int y = 0; y < m_row; y++) { m_ChrsBox[x][y] = createAChr(x, y); } } //判断是否是死图 while (isDeadMap()) { //这里稍后做一个更新的算法 for (int x = 0; x < m_col; x++) { for (int y = 0; y < m_row; y++) { m_ChrsBox[x][y]->removeFromParent(); m_ChrsBox[x][y] = createAChr(x, y); } } } //加入触摸监听 auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouches(true); listener->onTouchBegan = CC_CALLBACK_2(ChrsGrid::onTouchBegan, this); listener->onTouchMoved = CC_CALLBACK_2(ChrsGrid::onTouchMoved, this); listener->onTouchEnded = CC_CALLBACK_2(ChrsGrid::onTouchEnded, this); listener->onTouchCancelled = CC_CALLBACK_2(ChrsGrid::onTouchCancelled, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); //开始提示倒计时 resetCountdown(); schedule(schedule_selector(ChrsGrid::onCountdownCallBack), 1); log("ChrsGrid init!"); return true; }