Esempio n. 1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent), m_ApplicationOpenReminderEnabled(true),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    setWindowTitle(Version::getApplicationName().append(" (Version ").append(Version::getApplicationVersion().append(")")));
    setWindowIcon(QIcon(":/icon.ico"));

    createShortcuts();

    m_GraphicsScene = new GraphicalGridScene(m_Crossword);
    ui->graphicsView->setScene(m_GraphicsScene);

    m_TableModel = new CrosswordEntryTableModel(m_Crossword, m_Crossword.getRefEntries());
    m_ProxyModel = new QSortFilterProxyModel(this);
    m_ProxyModel->setSourceModel(m_TableModel);
    ui->wordTableView->setModel(m_ProxyModel);

    m_IdleReminder = new IdleReminder(60000);
    m_ClueReader = new ClueReader();

    connect(this, SIGNAL(puzzleLoaded()), m_TableModel, SLOT(crosswordEntriesChanged()));
    connect(this, SIGNAL(puzzleLoaded()), ui->wordTableView, SLOT(setFocus(Qt::OtherFocusReason)));
    connect(this, SIGNAL(puzzleLoaded()), m_GraphicsScene, SLOT(buildPuzzleGrid()));

    connect(m_TableModel, SIGNAL(conflictingWordError()), ui->wordTableView, SLOT(conflictingWordError()));
    connect(ui->wordTableView, SIGNAL(modelIndexChanged(const QModelIndex&, const QModelIndex&)), m_TableModel, SLOT(tableViewSelectionChanged(const QModelIndex&, const QModelIndex&)));

    connect(ui->wordTableView, SIGNAL(guessSubmitted(QString,QModelIndex)), this, SLOT(checkIfPuzzleWasCompleted()));
    connect(ui->wordTableView, SIGNAL(guessSubmitted(QString, QModelIndex)), m_TableModel, SLOT(enterGuess(QString, QModelIndex)));
    connect(ui->wordTableView, SIGNAL(guessAmendationRequested(QString, QModelIndex)), m_TableModel, SLOT(amendGuess(QString, QModelIndex)));
    connect(ui->wordTableView, SIGNAL(guessErasureRequested(QModelIndex)), m_TableModel, SLOT(eraseGuess(QModelIndex)));

    connect(m_TableModel, SIGNAL(guessValidated(QString)), ui->wordTableView, SLOT(reportGuessAccepted(QString)));
    connect(m_TableModel, SIGNAL(guessAmended(QString)), ui->wordTableView, SLOT(reportGuessAmended(QString)));
    connect(m_TableModel, SIGNAL(guessErased()), ui->wordTableView, SLOT(reportGuessErased()));
    connect(m_TableModel, SIGNAL(guessAmendationRequestRejected()), ui->wordTableView, SLOT(reportGuessAmendationRejected()));

    connect(m_TableModel, SIGNAL(guessValidated(QString)), m_GraphicsScene, SLOT(repaintPuzzleGrid()));
    connect(m_TableModel, SIGNAL(guessAmended(QString)), m_GraphicsScene, SLOT(repaintPuzzleGrid()));
    connect(m_TableModel, SIGNAL(guessErased()), m_GraphicsScene, SLOT(repaintPuzzleGrid()));
    connect(m_TableModel, SIGNAL(crosswordEntrySelectionChanged(CrosswordEntry)), m_GraphicsScene, SLOT(highlightSelection(CrosswordEntry)));

    connect(&m_CrosswordLoader, SIGNAL(loaderError(QString, QString)), this, SLOT(showError(QString, QString)));

    connect(m_IdleReminder, SIGNAL(timedOut()), this, SLOT(onIdleReminderTimeout()));
    qApp->installEventFilter(m_IdleReminder);

    connect(m_TableModel, SIGNAL(crosswordEntrySelectionChanged(CrosswordEntry)), m_ClueReader, SLOT(setText(CrosswordEntry)));

    ITextToSpeech::instance().speak(getIntroString());
}
Esempio n. 2
0
void CaptchaFormsPlugin::eventActivated(const QString& from)
{
    int index = findChalleng("sender", from);
    if(index == -1)
        return;

    QHash<QString, QString> dataFields = challenges_.at(index);
    QString id = dataFields.value("id");
    QPointer<CaptchaDialog> cd = new CaptchaDialog(id);
    cd->setBody(dataFields.value("body"));
    cd->setQuestion(dataFields.value("label"));
    connect(cd, SIGNAL(ok(QString, QString)), this, SLOT(submitChallenge(QString, QString)));
    connect(cd, SIGNAL(cancel(QString)), this, SLOT(cancelChallenge(QString)));
    dialogs_[id] = cd;


    if(dataFields.contains("data")) {
        QByteArray ba;
        ba.append(dataFields.value("data"));
        QPixmap pix = QPixmap::fromImage(QImage::fromData(QByteArray::fromBase64(ba)));
        cd->setPixmap(pix);
    }
    else {
        Loader *ld = new Loader(id, this);
        if(useProxy) {
            int acc = dataFields.value("account").toInt();
            QString host_ = accInfo->proxyHost(acc);
            if(!host_.isEmpty()) {
                ld->setProxy(host_, accInfo->proxyPort(acc), accInfo->proxyUser(acc), accInfo->proxyPassword(acc));
            }
        }
        else {
            Proxy p = appInfo->getProxyFor(name());
            ld->setProxy(p.host, p.port, p.user, p.pass);
        }
        QString url = dataFields.value("uri");
        if(url.isEmpty()) {
            QString str = dataFields.value("body");
            QRegExp re(".*(http://[^\"]+).*");
            if(re.indexIn(str) != -1)
                url = re.cap(1) + "/image";
        }
        ld->start(url);
        connect(ld, SIGNAL(data(QString,QByteArray)), SLOT(loaderData(QString, QByteArray)));
        connect(ld, SIGNAL(error(QString)), SLOT(loaderError(QString)));
    }
    cd->show();
}
Esempio n. 3
0
void Document::init(const QString& filePath, const QString& mimeType) {
  m_filePath = filePath;
  emit filePathChanged();

  m_mimeType = mimeType;
  emit mimeTypeChanged();

  setState(Document::Loading);

  if (!m_pages.isEmpty()) {
    emit aboutToReset();
    clearPages();
  }

  clearDocument();

  m_loader = new DocumentLoader;
  QObject::connect(m_loader, SIGNAL(done()), this, SLOT(loaderDone()));
  QObject::connect(m_loader, SIGNAL(error()), this, SLOT(loaderError()));
  QObject::connect(m_loader, SIGNAL(locked()), this, SLOT(loaderLocked()));
  m_loader->start(m_filePath, m_mimeType);
}