Beispiel #1
0
void AdGraphicsView::init()
{
    width = this->adMap.width();
    height = this->adMap.height();
    QLabel *cornerLabel = new QLabel(QStringLiteral("¹ã¸æ"));

    adScene = new QGraphicsScene(this);

    adScene->setSceneRect(-width/2, -height/2, width, height);

    this->setScene(adScene);
    this->setCacheMode(CacheBackground);

    QVBoxLayout *advLayout = new QVBoxLayout;
    advLayout->addWidget(cornerLabel);
    advLayout->setMargin(15);
    advLayout->addStretch();

    QHBoxLayout *adhLayout = new QHBoxLayout;
    adhLayout->addLayout(advLayout);
    adhLayout->addStretch();
    adhLayout->setDirection(QBoxLayout::RightToLeft);

    this->setLayout(adhLayout);
}
CBibleKeyChooser::CBibleKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent) :
        CKeyChooser(modules, key, parent),
        m_key(dynamic_cast<CSwordVerseKey*>(key)) {
    w_ref = 0;
    setModules(modules, false);
    if (!m_modules.count()) {
        qWarning() << "CBibleKeyChooser: module is not a Bible or commentary!";
        m_key = 0;
        return;
    }
    QHBoxLayout* layout = new QHBoxLayout(this);
    layout->setSpacing(0);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setDirection( QBoxLayout::LeftToRight );

    w_ref = new CKeyReferenceWidget(dynamic_cast<CSwordBibleModuleInfo*>(m_modules.first()), m_key, this);
    setFocusProxy(w_ref);
    layout->addWidget(w_ref);

    connect(w_ref, SIGNAL(beforeChange(CSwordVerseKey *)), SLOT(beforeRefChange(CSwordVerseKey *)));
    connect(w_ref, SIGNAL(changed(CSwordVerseKey *)), SLOT(refChanged(CSwordVerseKey *)));

    setKey(m_key); //set the key without changing it, setKey(key()) would change it

    connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
}
bool MainElement::CreateDialog(QString s)
{
    QPushButton okButton,cancelButton;

    okButton.setText(tr("OK"));
    cancelButton.setText(tr("Cancel"));

    QHBoxLayout layout;

    layout.addWidget(&cancelButton);
    layout.addWidget(&okButton);

    QLabel text;

    text.setText(s);
    layout.setDirection(QBoxLayout::BottomToTop);
    layout.addWidget(&text);

     question->setLayout(&layout);

     QObject::connect(&okButton, SIGNAL(clicked()), question, SLOT(accept()));
     QObject::connect(&cancelButton, SIGNAL(clicked()), question, SLOT(reject()));
     question->setVisible(true);
     question->show();
     question->exec();

     if(question->result() == QDialog::Accepted)
         return true;

     if(question->result() == QDialog::Rejected)
         return false;

}
 void updateLayoutDirection()
 {
     QBoxLayout::Direction direction;
     switch(m_edge) {
     case Unity2dPanel::TopEdge:
         direction = QBoxLayout::LeftToRight;
         break;
     case Unity2dPanel::LeftEdge:
         direction = QBoxLayout::TopToBottom;
         break;
     }
     m_layout->setDirection(direction);
 }
Beispiel #5
0
void VqbSchemaForm::init()
{
    /* Layouts and visual elements */

    d->btnAdd = new QPushButton("New Query Tree");   // add button
    d->btnAdd->setStatusTip("Adds a new query tree");
    d->btnAdd->setBaseSize(100, 50);
    connect(d->btnAdd, SIGNAL(clicked()), this, SLOT(addQueryTree()));

    QHBoxLayout *qhbl = new QHBoxLayout; //button's layout
    qhbl->setDirection(QBoxLayout::RightToLeft);
    qhbl->addWidget(d->btnAdd, 1);
    qhbl->addStretch(10);

    QVBoxLayout* layout = new QVBoxLayout();
    setLayout(layout);

    d->topLayout = new QVBoxLayout; //the top QueryTree stack
    layout->addLayout(d->topLayout, 1);
    layout->addLayout(qhbl, 1);  //the bottom layout (holding the button)
    layout->addStretch(5);

    addQueryTree();
}
Beispiel #6
0
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget),
    m_pData(new Widget::Private())
{
    ui->setupUi(this);
    QComboBox *cityList = new QComboBox(this);
    cityList->addItem(tr("Beijing"), QLatin1String("Beijing, cn"));
    cityList->addItem(tr("Shanghai"), QLatin1String("Shanghai, cn"));
    cityList->addItem(tr("Nanjing"), QLatin1String("Nanjing, cn"));

    QLabel* cityLabel = new QLabel(tr("City:"), this);
    QPushButton *refreshButton = new QPushButton(tr("Refresh"), this);
    QHBoxLayout *cityListLayout = new QHBoxLayout;
    cityListLayout->setDirection(QBoxLayout::LeftToRight);
    cityListLayout->addWidget(cityLabel);
    cityListLayout->addWidget(cityList);
    cityListLayout->addWidget(refreshButton);

    QVBoxLayout *weatherLayout = new QVBoxLayout;
    weatherLayout->setDirection(QBoxLayout::TopToBottom);
    QLabel* cityNameLabel = new QLabel(this);
    weatherLayout->addWidget(cityNameLabel);
    QLabel *dateTimeLabel = new QLabel(this);
    weatherLayout->addWidget(dateTimeLabel);

    m_pData->descLabel = new QLabel(this);
    weatherLayout->addWidget(m_pData->descLabel);
    m_pData->iconLabel = new QLabel(this);
    weatherLayout->addWidget(m_pData->iconLabel);

    QVBoxLayout* mainLayout = new QVBoxLayout(this);
    mainLayout->addLayout(cityListLayout);
    mainLayout->addLayout(weatherLayout);
    resize(320, 120);
    setWindowTitle("Weather");

    connect(m_pData->network, &NetWorker::finished, [=](QNetworkReply* reply){
        switch(m_pData->replyMap.value(reply))
        {
        case FetchWeatherInfo:
            {
                QJsonParseError error;
                QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);

                if(error.error == QJsonParseError::NoError){
                    if(!(jsonDoc.isNull() || jsonDoc.isEmpty()) && (jsonDoc.isObject())){
                        QVariantMap data = jsonDoc.toVariant().toMap();
                        WeatherInfo weather;
                        weather.setCityName(data[QLatin1String("name")].toString());
                        QDateTime dateTime;
                        dateTime.setTime_t(data[QLatin1String("dt")].toLongLong());
                        weather.setDateTime(dateTime);
                        QVariantMap main = data[QLatin1String("main")].toMap();
                        weather.setTempertuare(main[QLatin1String("temp")].toFloat());
                        weather.setPressure(main[QLatin1String("pressure")].toFloat());
                        weather.setHumidity(main[QLatin1String("humidity")].toFloat());
                        QVariantList detaiList = data[QLatin1String("weather")].toList();
                        WeatherDetailList details;
                        foreach (QVariant w, detaiList) {
                            QVariantMap wm = w.toMap();
                            WeatherDetail *detail = new WeatherDetail;
                            detail->setDesc(wm[QLatin1String("description")].toString());
                            detail->setIcon(wm[QLatin1Literal("icon")].toString());
                            details.append(detail);
                        }
                        weather.setDetails(details);
                        cityNameLabel->setText(weather.cityName());
                        dateTimeLabel->setText(weather.dateTime().toString(Qt::DefaultLocaleLongDate));
                        m_pData->descLabel->setText(weather.details().at(0)->desc());
                        qDebug()<<weather;
                    }
                    else{
                        QMessageBox::critical(this, "Error","Parse Reply Error!");
                    }
                }
            }