diff options
Diffstat (limited to 'quacker')
-rw-r--r-- | quacker/boarddisplay.cpp | 28 | ||||
-rw-r--r-- | quacker/boarddisplay.h | 17 | ||||
-rw-r--r-- | quacker/configpages.cpp | 4 | ||||
-rw-r--r-- | quacker/configpages.h | 1 | ||||
-rw-r--r-- | quacker/graphicalreporter.cpp | 1 | ||||
-rw-r--r-- | quacker/letterbox.cpp | 9 | ||||
-rw-r--r-- | quacker/lister.cpp | 2 | ||||
-rw-r--r-- | quacker/quacker.cpp | 15 | ||||
-rw-r--r-- | quacker/quackersettings.cpp | 2 |
9 files changed, 73 insertions, 6 deletions
diff --git a/quacker/boarddisplay.cpp b/quacker/boarddisplay.cpp index 9dd49da..85b551b 100644 --- a/quacker/boarddisplay.cpp +++ b/quacker/boarddisplay.cpp @@ -32,8 +32,9 @@ BoardWithQuickEntry::BoardWithQuickEntry(QWidget *parent) m_vlayout = new QVBoxLayout(this); Geometry::setupInnerLayout(m_vlayout); - m_lineEdit = new QLineEdit; + m_lineEdit = new QLineEditWithShiftReturn; connect(m_lineEdit, SIGNAL(returnPressed()), this, SLOT(quickEditReturnPressed())); + connect(m_lineEdit, SIGNAL(shiftReturnPressed()), this, SLOT(quickEditShiftReturnPressed())); QLabel *placeLabel = new QLabel(tr("Move: '<position> <word>' or 'exchange <tiles|number>'")); placeLabel->setBuddy(m_lineEdit); @@ -96,6 +97,13 @@ void BoardWithQuickEntry::quickEditReturnPressed() m_lineEdit->clear(); } +void BoardWithQuickEntry::quickEditShiftReturnPressed() +{ + quickEditReturnPressed(); + performCommit(); + m_lineEdit->setFocus(); +} + void BoardWithQuickEntry::plusFive() { m_localCandidateMove.setScoreAddition(m_localCandidateMove.scoreAddition() + 5); @@ -170,7 +178,7 @@ void BoardWithQuickEntry::processCommand(const QString &command) if (isPass) move = Quackle::Move::createPassMove(); else - move = Quackle::Move::createExchangeMove(encodedLetters); + move = Quackle::Move::createExchangeMove(encodedLetters, isIntConvertable); } else { @@ -217,3 +225,19 @@ void TextBoard::positionChanged(const Quackle::GamePosition &position) //m_textEdit->setHtml(QString("<html><font size=\"+4\"><pre>%1</pre></font></html>").arg(QuackleIO::Util::uvStringToQString(position.boardAfterMoveMade().toString()))); m_textEdit->setPlainText(QString("%1").arg(QuackleIO::Util::uvStringToQString(position.boardAfterMoveMade().toString()))); } + +/////////// + +void QLineEditWithShiftReturn::keyPressEvent(QKeyEvent * e) +{ + if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) + { + if (e->modifiers() & Qt::ShiftModifier) + { + emit shiftReturnPressed(); + return; + } + } + QLineEdit::keyPressEvent(e); +} + diff --git a/quacker/boarddisplay.h b/quacker/boarddisplay.h index 35ebcb7..fbb71c1 100644 --- a/quacker/boarddisplay.h +++ b/quacker/boarddisplay.h @@ -22,8 +22,10 @@ #include <move.h> #include "view.h" +#include <QLineEdit> class QLineEdit; +class QLineEditWithShiftReturn; class QPushButton; class QTextEdit; class QVBoxLayout; @@ -49,6 +51,7 @@ protected slots: private slots: void quickEditReturnPressed(); + void quickEditShiftReturnPressed(); void plusFive(); void performCommit(); void reset(); @@ -60,7 +63,7 @@ protected: QVBoxLayout *m_vlayout; private: - QLineEdit *m_lineEdit; + QLineEditWithShiftReturn *m_lineEdit; QPushButton *m_commitButton; Quackle::Move m_localCandidateMove; }; @@ -79,4 +82,16 @@ private: QTextEdit *m_textEdit; }; +class QLineEditWithShiftReturn : public QLineEdit +{ +Q_OBJECT + +signals: + void shiftReturnPressed(); + +public: + virtual void keyPressEvent(QKeyEvent * e); +}; + + #endif diff --git a/quacker/configpages.cpp b/quacker/configpages.cpp index c246797..ee807fd 100644 --- a/quacker/configpages.cpp +++ b/quacker/configpages.cpp @@ -96,10 +96,12 @@ InterfacePage::InterfacePage(QWidget *parent) QGroupBox *miscellanyGroup = new QGroupBox(tr("Miscellany")); m_vowelFirstCheck = new QCheckBox(tr("&Vowel-first alphabetizing")); m_octothorpCheck = new QCheckBox(tr("&Octothorp British words")); + m_scoreInvalidAsZero = new QCheckBox(tr("&Score 0 for plays with illegal words")); QGridLayout *miscellanyLayout = new QGridLayout; miscellanyLayout->addWidget(m_vowelFirstCheck, 0, 0); miscellanyLayout->addWidget(m_octothorpCheck, 1, 0); + miscellanyLayout->addWidget(m_scoreInvalidAsZero, 2, 0); miscellanyGroup->setLayout(miscellanyLayout); QVBoxLayout *mainLayout = new QVBoxLayout; @@ -116,6 +118,7 @@ void InterfacePage::readConfig() m_verboseLabelsCheck->setChecked(QuackerSettings::self()->verboseLabels); m_scoreLabelsCheck->setChecked(QuackerSettings::self()->scoreLabels); m_octothorpCheck->setChecked(QuackleIO::UtilSettings::self()->octothorpBritish); + m_scoreInvalidAsZero->setChecked(QuackleIO::UtilSettings::self()->scoreInvalidAsZero); } void InterfacePage::writeConfig() @@ -125,5 +128,6 @@ void InterfacePage::writeConfig() QuackerSettings::self()->verboseLabels = m_verboseLabelsCheck->isChecked(); QuackerSettings::self()->scoreLabels = m_scoreLabelsCheck->isChecked(); QuackleIO::UtilSettings::self()->octothorpBritish = m_octothorpCheck->isChecked(); + QuackleIO::UtilSettings::self()->scoreInvalidAsZero = m_scoreInvalidAsZero->isChecked(); } diff --git a/quacker/configpages.h b/quacker/configpages.h index 6d02ec0..6b61375 100644 --- a/quacker/configpages.h +++ b/quacker/configpages.h @@ -52,6 +52,7 @@ private: QCheckBox *m_verboseLabelsCheck; QCheckBox *m_scoreLabelsCheck; QCheckBox *m_octothorpCheck; + QCheckBox *m_scoreInvalidAsZero; QComboBox *m_britishColoringCombo; }; diff --git a/quacker/graphicalreporter.cpp b/quacker/graphicalreporter.cpp index 2fb0842..a7ca9f5 100644 --- a/quacker/graphicalreporter.cpp +++ b/quacker/graphicalreporter.cpp @@ -192,6 +192,7 @@ void GraphicalReporter::reportPosition(const Quackle::GamePosition &position, Qu } case Quackle::Move::Exchange: + case Quackle::Move::BlindExchange: default: item = QuackleIO::Util::moveToDetailedString(*it); break; diff --git a/quacker/letterbox.cpp b/quacker/letterbox.cpp index 399b73a..04213d7 100644 --- a/quacker/letterbox.cpp +++ b/quacker/letterbox.cpp @@ -232,6 +232,7 @@ void Letterbox::loadFile() QTextStream stream(&file); QString line; + stream.setCodec(QTextCodec::codecForName("UTF-8")); m_initializationChuu = true; @@ -517,6 +518,7 @@ void Letterbox::outputResults() } QTextStream stream(&file); + stream.setCodec(QTextCodec::codecForName("UTF-8")); if (m_numberIterator < m_clueResults.count()) stream << "\" Resume: " << m_numberIterator << "\n"; @@ -553,6 +555,7 @@ void Letterbox::outputResults() } QTextStream stream(&missesFile); + stream.setCodec(QTextCodec::codecForName("UTF-8")); for (ClueResultList::iterator it = m_clueResults.begin(); it != m_clueResults.end(); ++it) { @@ -918,6 +921,7 @@ void Letterbox::print() setModified(wasModified); QTextStream stream(&file); + stream.setCodec(QTextCodec::codecForName("UTF-8")); stream << printer.html() << "\n"; file.close(); @@ -948,6 +952,7 @@ void Letterbox::printStudy() jumpTo(m_clueResults.size() - 1); QTextStream stream(&file); + stream.setCodec(QTextCodec::codecForName("UTF-8")); stream << generateStudySheet(m_answers.begin(), m_answers.end()) << "\n"; file.close(); @@ -1169,7 +1174,9 @@ void HTMLRepresentation::setHTML(const QString &text, ContentType type) QString HTMLRepresentation::html() { - return m_html; + return QString("<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n</head>\n<body>") + + m_html + + QString("</body></html>"); } void HTMLRepresentation::setWords(ClueResultList::ConstIterator start, ClueResultList::ConstIterator end, bool revers) diff --git a/quacker/lister.cpp b/quacker/lister.cpp index be3e335..08e2405 100644 --- a/quacker/lister.cpp +++ b/quacker/lister.cpp @@ -233,6 +233,7 @@ void ListerDialog::openFile() if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream stream(&file); + stream.setCodec(QTextCodec::codecForName("UTF-8")); QString line; while (!stream.atEnd()) { @@ -430,6 +431,7 @@ QString ListerDialog::writeList(bool alphagrams) } QTextStream stream(&file); + stream.setCodec(QTextCodec::codecForName("UTF-8")); QMap<QString, Dict::WordList> map(anagramMap()); diff --git a/quacker/quacker.cpp b/quacker/quacker.cpp index 6b5becb..ffe6531 100644 --- a/quacker/quacker.cpp +++ b/quacker/quacker.cpp @@ -297,6 +297,7 @@ void TopLevel::setCandidateMove(const Quackle::Move &move) if (!m_game->hasPositions() || (move.action == Quackle::Move::Place && move.tiles().empty())) return; + bool playHasIllegalWords = false; Quackle::Move prettiedMove(move); m_game->currentPosition().ensureMoveTilesDoNotIncludePlayThru(prettiedMove); m_game->currentPosition().ensureMovePrettiness(prettiedMove); @@ -367,6 +368,8 @@ void TopLevel::setCandidateMove(const Quackle::Move &move) { prettiedMove.setIsChallengedPhoney(true); } + else + playHasIllegalWords = true; } validityFlags ^= Quackle::GamePosition::UnacceptableWord; @@ -384,13 +387,18 @@ void TopLevel::setCandidateMove(const Quackle::Move &move) if (!carryOn) return; - m_game->currentPosition().scoreMove(prettiedMove); + if (playHasIllegalWords && QuackleIO::UtilSettings::self()->scoreInvalidAsZero) + prettiedMove.score = 0; + else + m_game->currentPosition().scoreMove(prettiedMove); m_game->currentPosition().addAndSetMoveMade(prettiedMove); switchToTab(ChoicesTabIndex); ensureUpToDateSimulatorMoveList(); } - if (!m_game->currentPosition().currentPlayer().racksAreKnown() && !m_game->currentPosition().currentPlayer().rack().contains(prettiedMove.usedTiles())) + if (!m_game->currentPosition().currentPlayer().racksAreKnown() && + !m_game->currentPosition().currentPlayer().rack().contains(prettiedMove.usedTiles()) && + prettiedMove.action != Quackle::Move::BlindExchange) { m_game->currentPosition().setCurrentPlayerRack(Quackle::Rack(prettiedMove.usedTiles())); } @@ -1319,6 +1327,7 @@ void TopLevel::reportAs(Quackle::ComputerPlayer *player) Quackle::ComputerPlayer *clone = player->clone(); QTextStream stream(&file); + stream.setCodec(QTextCodec::codecForName("UTF-8")); QuackleIO::StreamingReporter::reportGame(*m_game, clone, stream); delete clone; } @@ -2077,6 +2086,7 @@ void TopLevel::writeAsciiToFile(const QString &text, const QString &filename) } QTextStream stream(&file); + stream.setCodec(QTextCodec::codecForName("UTF-8")); stream << text << "\n"; file.close(); @@ -2102,6 +2112,7 @@ void TopLevel::print() } QTextStream stream(&file); + stream.setCodec(QTextCodec::codecForName("UTF-8")); //stream << printer.html() << "\n"; file.close(); diff --git a/quacker/quackersettings.cpp b/quacker/quackersettings.cpp index 1889848..510e43a 100644 --- a/quacker/quackersettings.cpp +++ b/quacker/quackersettings.cpp @@ -45,6 +45,7 @@ void QuackerSettings::readSettings() scoreLabels = settings.value("quackle/settings/score-labels", scoreLabels).toBool(); QuackleIO::UtilSettings::self()->vowelFirst = settings.value("quackle/settings/vowel-first", QuackleIO::UtilSettings::self()->vowelFirst).toBool(); QuackleIO::UtilSettings::self()->octothorpBritish = settings.value("quackle/settings/octothorp-british", QuackleIO::UtilSettings::self()->octothorpBritish).toBool(); + QuackleIO::UtilSettings::self()->scoreInvalidAsZero = settings.value("quackle/settings/score-invalid-as-zero", QuackleIO::UtilSettings::self()->scoreInvalidAsZero).toBool(); m_letterboxSettings.readSettings(); } @@ -57,6 +58,7 @@ void QuackerSettings::writeSettings() settings.setValue("quackle/settings/score-labels", scoreLabels); settings.setValue("quackle/settings/vowel-first", QuackleIO::UtilSettings::self()->vowelFirst); settings.setValue("quackle/settings/octothorp-british", QuackleIO::UtilSettings::self()->octothorpBritish); + settings.setValue("quackle/settings/score-invalid-as-zero", QuackleIO::UtilSettings::self()->scoreInvalidAsZero); m_letterboxSettings.writeSettings(); } |