void FoursquareAuthPage::createContent(void)
{
	MApplicationPage::createContent();
	setStyleName("CommonApplicationPage");
	setPannable(false);

	MAction *cancelAction = new MAction(tr("Cancel"), this);
	cancelAction->setLocation(MAction::ToolBarLocation);
	connect(cancelAction, SIGNAL(triggered()),
		this, SLOT(dismiss()));
	addAction(cancelAction);

	QGraphicsAnchorLayout *layout = new QGraphicsAnchorLayout();
	layout->setContentsMargins(0, 0, 0, 0);

	m_header = new ViewHeader(tr("Foursquare authentication"));

	layout->addCornerAnchors(m_header, Qt::TopLeftCorner,
				 layout, Qt::TopLeftCorner);
	layout->addCornerAnchors(m_header, Qt::TopRightCorner,
				 layout, Qt::TopRightCorner);

	QGraphicsGridLayout *subLayout = new QGraphicsGridLayout();
	layout->addCornerAnchors(subLayout, Qt::TopLeftCorner,
				 m_header, Qt::BottomLeftCorner);
 	layout->addCornerAnchors(subLayout, Qt::BottomRightCorner,
 				 layout, Qt::BottomRightCorner);

	m_view = new QGraphicsWebView();
	m_view->setResizesToContents(false);
	m_view->setSizePolicy(QSizePolicy::Ignored,
			      QSizePolicy::Ignored);
	connect(m_view, SIGNAL(loadStarted()),
		this, SLOT(pageLoadStarted()));
	connect(m_view, SIGNAL(loadFinished(bool)),
		this, SLOT(pageLoadFinished(bool)));

	subLayout->addItem(m_view, 0, 0);

	m_nam = new FoursquareAuthNetworkAccessManager(m_view->page()->networkAccessManager(), 
						       REDIRECT_URL,
						       this);
	connect(m_nam, SIGNAL(tokenReceived(QString)),
		this, SLOT(tokenReceived(QString)));

	m_view->page()->setNetworkAccessManager(m_nam);

	centralWidget()->setLayout(layout);

	Q_EMIT(created());
}
Esempio n. 2
0
TKN_Window::TKN_Window(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::TKN_Window)
{
    /* Ui setup */
    ui->setupUi(this);
    ui->buttonStartStop->setText(buttonStartText);
    self = this;
    mTime = new QTime();
    int i;

    /* available ports */
    char** port_list = listSerialPorts();
    if (port_list){
        for (i=0; *port_list; i++, port_list++)
            ui->comboBox_ComPort->insertItem(i, QString(*port_list));
    }

    /* baud rates */
    for (i=0; i<sizeof(baudList)/sizeof(baudList[0]) ; i++)
        ui->comboBox_Baud->insertItem(i, baudList[i]);

    this->mTknStarted = false;

    /* Signal connections */
    connect(this, SIGNAL(tokenReceived()), this, SLOT(onTokenReceived()), Qt::QueuedConnection);
    connect(this, SIGNAL(dataReady()), this, SLOT(dataReceive()), Qt::QueuedConnection);

    this->ui->labelAVR->setPixmap( QPixmap(":/AVR_Chip-W180px.png"));
    this->updateUI();
}
Esempio n. 3
0
void LastFMAuth::replyReceived(QNetworkReply *reply)
{
    if (reply->error() != QNetworkReply::NoError)
    {
        if (_errorString)
            *_errorString = reply->errorString();
        State old = _state;
        _state = Idle;
        switch (old)
        {
        case RequestingToken:
            emit tokenReceived(true);
            return;
        case RequestingSession:
            emit sessionReceived(true);
            return;
        default: return;
        }
    }

    if (_state == RequestingToken)
    {
        QDomDocument document;
        QString data;
        document.setContent(reply);
        QDomElement elem = document.firstChildElement("lfm").firstChildElement("error");
        data = elem.text();
        if (!data.isEmpty())
        {
            if (_errorString)
                *_errorString = data;
            emit tokenReceived(true);
        }
        else
        {
            _token = document.firstChildElement("lfm").firstChildElement("token").text();
            emit tokenReceived(false);
        }
    }
    else if (_state == RequestingSession)
    {
        QDomDocument document;
        QString data;
        document.setContent(reply);
        QDomElement elem = document.firstChildElement("lfm").firstChildElement("error");
        data = elem.text();
        if (!data.isEmpty())
        {
            if (_errorString)
                *_errorString = data;
            emit sessionReceived(true);
        }
        else
        {
            _session = document.firstChildElement("lfm").firstChildElement("session").firstChildElement("key").text();
            emit sessionReceived(false);
        }
    }

    _state = Idle;
}