TextInput::TextInput(QWidget* parent) : QLineEdit(parent) { setAttribute(Qt::WA_MacShowFocusRect, false); d.hint = "..."; d.index = 0; d.buffer = 0; d.parser = 0; d.completer = new IrcCompleter(this); connect(this, SIGNAL(bufferChanged(IrcBuffer*)), d.completer, SLOT(setBuffer(IrcBuffer*))); connect(this, SIGNAL(parserChanged(IrcCommandParser*)), d.completer, SLOT(setParser(IrcCommandParser*))); connect(d.completer, SIGNAL(completed(QString,int)), this, SLOT(doComplete(QString,int))); connect(this, SIGNAL(textEdited(QString)), d.completer, SLOT(reset())); connect(this, SIGNAL(returnPressed()), this, SLOT(sendInput())); connect(this, SIGNAL(textChanged(QString)), this, SLOT(updateHint(QString))); }
void GameLayer::consumeHint(){ Stats::hintNum --; updateHint(); }
bool GameLayer::init() { if (!CCLayer::init()) { return false; } char buffer[30]; _numBoardBatch = CCArray::createWithCapacity(9); _numBoardBatch->retain(); for(int i = 1; i <= 9; i++) { sprintf(buffer, "tileStyle/pn/%d.png", i); CCSpriteBatchNode* batchNode = CCSpriteBatchNode::create(buffer); _numBoardBatch->addObject(batchNode); } CCSprite * background = CCSprite::create("tileStyle/background.jpg"); background->setPosition(ccp(240, 400)); this->addChild(background); _back = CCSprite::create("back.png"); _back->setPosition(ccp(24 + 40, 800 - 56.5 + 15)); this->addChild(_back); _restart = CCSprite::create("tileStyle/restart.png"); _restart->setPosition(ccp(375 + 40, 800 - 56.5 + 15)); this->addChild(_restart); _timer = CCLabelTTF::create("0", "Verdana-Bold", 30); _timer->setPosition(ccp(240, 800 - 13 - 20)); _timer->setVisible(Settings::showTimer); this->addChild(_timer); _numButtons = CCArray::createWithCapacity(9); _numButtons->retain(); _numNote = CCArray::createWithCapacity(9); _numNote->retain(); _numNoteBatch = CCArray::createWithCapacity(9); _numNoteBatch->retain(); _backPlanes = CCArray::createWithCapacity(9); _backPlanes->retain(); CCSpriteBatchNode* backPlaneBatch = CCSpriteBatchNode::create("tileStyle/backplane.png"); for(int i = 1; i <= 9; i++) { sprintf(buffer, "tileStyle/numb/%d.png", i); CCSprite * num = CCSprite::create(buffer); num->setZOrder(4); _numButtons->addObject(num); sprintf(buffer, "tileStyle/noteb/%d.png", i); CCSpriteBatchNode* noteBatch = CCSpriteBatchNode::create(buffer); _numNoteBatch->addObject(noteBatch); CCSprite * note = CCSprite::createWithTexture(noteBatch->getTexture()); _numNote->addObject(note); CCSprite * backPlane = CCSprite::createWithTexture(backPlaneBatch->getTexture()); _backPlanes->addObject(backPlane); } int k; for (int order = 0; order < 2; order++) { for (int i = 0; i < 5 - order; i++) { k = 2 * i + order; CCSprite * num = (CCSprite*)_numButtons->objectAtIndex(k); num->setPosition(ccp(BX_START + k * BX_STEP, BY[order])); num->setVisible(Sudoku::state == Running); this->addChild(num); CCSprite * note = (CCSprite *)_numNote->objectAtIndex(k); note->setPosition(ccp(BX_START + k * BX_STEP, BY[order])); note->setVisible(Sudoku::state == Note); this->addChild(note); CCSprite * backPlane = (CCSprite *)_backPlanes->objectAtIndex(k); backPlane->setPosition(ccp(BX_START + k * BX_STEP, BY[order])); this->addChild(backPlane); } } updateBackplane(); _hint = CCLabelTTF::create("5", "Verdana-Bold", 32); _hint->setPosition(ccp(12 + 33 - 2, 800 - 704 - 33 + 2)); _hint->setColor(ccc3(0, 0, 0)); updateHint(); this->addChild(_hint); CCSprite * magnifierGlass = CCSprite::create("tileStyle/hint.png"); magnifierGlass->setPosition(ccp(12 + 33, 800 - 704 - 33)); this->addChild(magnifierGlass); _pencilToNote = CCSprite::create("tileStyle/pencil.png"); _pencilToNote->setPosition(ccp(401 + 33, 800 - 704 - 33)); _pencilToNote->setVisible(Sudoku::state == Running); this->addChild(_pencilToNote); _penToRun = CCSprite::create("tileStyle/pen.png"); _penToRun->setPosition(ccp(401 + 33, 800 - 704 - 33)); _penToRun->setVisible(Sudoku::state == Note); this->addChild(_penToRun); this->setTouchEnabled(true); this->setKeypadEnabled(true); this->schedule(schedule_selector(GameLayer::update)); return true; }
ColoringRulesDialog::ColoringRulesDialog(QWidget *parent, QString add_filter) : GeometryStateDialog(parent), ui(new Ui::ColoringRulesDialog), colorRuleModel_(palette().color(QPalette::Text), palette().color(QPalette::Base), this), colorRuleDelegate_(this) { ui->setupUi(this); if (parent) loadGeometry(parent->width() * 2 / 3, parent->height() * 4 / 5); setWindowTitle(wsApp->windowTitleString(tr("Coloring Rules %1").arg(get_profile_name()))); ui->coloringRulesTreeView->setModel(&colorRuleModel_); ui->coloringRulesTreeView->setItemDelegate(&colorRuleDelegate_); ui->coloringRulesTreeView->viewport()->setAcceptDrops(true); for (int i = 0; i < colorRuleModel_.columnCount(); i++) { ui->coloringRulesTreeView->resizeColumnToContents(i); } #ifdef Q_OS_MAC ui->newToolButton->setAttribute(Qt::WA_MacSmallSize, true); ui->deleteToolButton->setAttribute(Qt::WA_MacSmallSize, true); ui->copyToolButton->setAttribute(Qt::WA_MacSmallSize, true); ui->clearToolButton->setAttribute(Qt::WA_MacSmallSize, true); ui->pathLabel->setAttribute(Qt::WA_MacSmallSize, true); #endif connect(ui->coloringRulesTreeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(colorRuleSelectionChanged(const QItemSelection &, const QItemSelection &))); connect(&colorRuleDelegate_, SIGNAL(invalidField(const QModelIndex&, const QString&)), this, SLOT(invalidField(const QModelIndex&, const QString&))); connect(&colorRuleDelegate_, SIGNAL(validField(const QModelIndex&)), this, SLOT(validField(const QModelIndex&))); connect(&colorRuleModel_, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(rowCountChanged())); connect(&colorRuleModel_, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(rowCountChanged())); rowCountChanged(); import_button_ = ui->buttonBox->addButton(tr("Import" UTF8_HORIZONTAL_ELLIPSIS), QDialogButtonBox::ApplyRole); import_button_->setToolTip(tr("Select a file and add its filters to the end of the list.")); export_button_ = ui->buttonBox->addButton(tr("Export" UTF8_HORIZONTAL_ELLIPSIS), QDialogButtonBox::ApplyRole); export_button_->setToolTip(tr("Save filters in a file.")); QPushButton *copy_button = ui->buttonBox->addButton(tr("Copy from"), QDialogButtonBox::ActionRole); CopyFromProfileMenu *copy_from_menu = new CopyFromProfileMenu(COLORFILTERS_FILE_NAME, copy_button); copy_button->setMenu(copy_from_menu); copy_button->setToolTip(tr("Copy coloring rules from another profile.")); copy_button->setEnabled(copy_from_menu->haveProfiles()); connect(copy_from_menu, SIGNAL(triggered(QAction *)), this, SLOT(copyFromProfile(QAction *))); QString abs_path = gchar_free_to_qstring(get_persconffile_path(COLORFILTERS_FILE_NAME, TRUE)); if (file_exists(abs_path.toUtf8().constData())) { ui->pathLabel->setText(abs_path); ui->pathLabel->setUrl(QUrl::fromLocalFile(abs_path).toString()); ui->pathLabel->setToolTip(tr("Open ") + COLORFILTERS_FILE_NAME); ui->pathLabel->setEnabled(true); } if (!add_filter.isEmpty()) { colorRuleModel_.addColor(false, add_filter, palette().color(QPalette::Text), palette().color(QPalette::Base)); //setup the buttons appropriately ui->coloringRulesTreeView->setCurrentIndex(colorRuleModel_.index(0, 0)); //set edit on display filter ui->coloringRulesTreeView->edit(colorRuleModel_.index(0, 1)); }else { ui->coloringRulesTreeView->setCurrentIndex(QModelIndex()); } checkUnknownColorfilters(); updateHint(); }
void ColoringRulesDialog::validField(const QModelIndex &index) { if (errors_.remove(index) > 0) { updateHint(); } }
void ColoringRulesDialog::invalidField(const QModelIndex &index, const QString& errMessage) { errors_.insert(index, errMessage); updateHint(); }
MyCompleterLineEdit::MyCompleterLineEdit(QWidget *parent) : QLineEdit(parent), c(0) { connect(this,SIGNAL(textEdited(QString)),this,SLOT(updateHint())); }