示例#1
0
        void onCreate( SpinSlider * pThis ) {

            auto gridLayout = new QGridLayout( pThis );

            if ( orientation_ == Qt::Horizontal ) {
                gridLayout->setHorizontalSpacing(6);
                gridLayout->setVerticalSpacing(2);
            } else {
                gridLayout->setHorizontalSpacing(2);
                gridLayout->setVerticalSpacing(2);
            }
            onCreate( gridLayout, 0, 0, pThis );
        }
示例#2
0
CharacterModule::CharacterModule() : characterPortrait(NULL)
{
   characterStats = new gcn::contrib::AdjustingContainer();
   characterNameLabel = new edwt::Label();
   characterHPLabel = new edwt::Label();
   characterSPLabel = new edwt::Label();

   characterNameLabel->setForegroundColor(0xFFFFFF);
   characterHPLabel->setForegroundColor(0xFFFFFF);
   characterSPLabel->setForegroundColor(0xFFFFFF);

   characterPortrait = new edwt::Icon();

   characterStats->setNumberOfColumns(1);
   characterStats->setColumnAlignment(0, gcn::contrib::AdjustingContainer::LEFT);
   characterStats->add(characterNameLabel);
   characterStats->add(characterHPLabel);
   characterStats->add(characterSPLabel);
   characterStats->setOpaque(false);

   setNumberOfColumns(2);
   setColumnAlignment(0, gcn::contrib::AdjustingContainer::LEFT);
   setColumnAlignment(1, gcn::contrib::AdjustingContainer::RIGHT);
   setHorizontalSpacing(10);
   setPadding(5, 5, 5, 5);

   add(characterPortrait);
   add(characterStats);
   addMouseListener(this);
   setOpaque(false);
}
void MAbstractLayoutPolicy::applyStyle()
{
    Q_D(MAbstractLayoutPolicy);
    //Do not change the margins if the user manually set them or the margins
    //have not changed

    d->disableInvalidateLayoutAndPolicy = true;

    if (!d->userSetContentsMargins &&
            (d->marginLeft != (int)d->style->marginLeft() ||
             d->marginTop != (int)d->style->marginTop() ||
             d->marginRight != (int)d->style->marginRight() ||
             d->marginBottom != (int)d->style->marginBottom())) {
        d->marginLeft = (int)d->style->marginLeft();
        d->marginTop = (int)d->style->marginTop();
        d->marginRight = (int)d->style->marginRight();
        d->marginBottom = (int)d->style->marginBottom();
        invalidatePolicyAndLayout();
    }

    if (!d->userSetHorizontalSpacing) {
        setHorizontalSpacing(d->style->horizontalSpacing()); //This is a virtual function so we have to call it so that subclasses receive this
        d->userSetHorizontalSpacing = false;
    }

    if (!d->userSetVerticalSpacing) {
        setVerticalSpacing(d->style->verticalSpacing()); //This is a virtual function so we have to call it so that subclasses receive this
        d->userSetVerticalSpacing = false;
    }

    d->disableInvalidateLayoutAndPolicy = false;
    if (d->layoutInvalidateCalledWhileDisabled) {
        invalidatePolicyAndLayout();
    }
}
QgsDetailedItemDelegate::QgsDetailedItemDelegate( QObject * parent ) :
    QAbstractItemDelegate( parent ),
    mpWidget( new QgsDetailedItemWidget() ),
    mpCheckBox( new QCheckBox() )

{
  //mpWidget->setFixedHeight(80);
  mpCheckBox->resize( mpCheckBox->sizeHint().height(), mpCheckBox->sizeHint().height() );
  setVerticalSpacing( 3 );
  setHorizontalSpacing( 5 );
}
void MAbstractLayoutPolicy::setSpacing(qreal spacing)
{
    Q_D(MAbstractLayoutPolicy);
    d->disableInvalidateLayoutAndPolicy = true;

    setHorizontalSpacing(spacing);
    setVerticalSpacing(spacing);

    d->disableInvalidateLayoutAndPolicy = false;
    if (d->layoutInvalidateCalledWhileDisabled)
        invalidatePolicyAndLayout();
}
int QFormLayout::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QLayout::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< FieldGrowthPolicy*>(_v) = fieldGrowthPolicy(); break;
        case 1: *reinterpret_cast< RowWrapPolicy*>(_v) = rowWrapPolicy(); break;
        case 2: *reinterpret_cast< Qt::Alignment*>(_v) = labelAlignment(); break;
        case 3: *reinterpret_cast< Qt::Alignment*>(_v) = formAlignment(); break;
        case 4: *reinterpret_cast< int*>(_v) = horizontalSpacing(); break;
        case 5: *reinterpret_cast< int*>(_v) = verticalSpacing(); break;
        }
        _id -= 6;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setFieldGrowthPolicy(*reinterpret_cast< FieldGrowthPolicy*>(_v)); break;
        case 1: setRowWrapPolicy(*reinterpret_cast< RowWrapPolicy*>(_v)); break;
        case 2: setLabelAlignment(*reinterpret_cast< Qt::Alignment*>(_v)); break;
        case 3: setFormAlignment(*reinterpret_cast< Qt::Alignment*>(_v)); break;
        case 4: setHorizontalSpacing(*reinterpret_cast< int*>(_v)); break;
        case 5: setVerticalSpacing(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 6;
    } else if (_c == QMetaObject::ResetProperty) {
        switch (_id) {
        case 0: resetFieldGrowthPolicy(); break;
        case 1: resetRowWrapPolicy(); break;
        case 2: resetLabelAlignment(); break;
        case 3: resetFormAlignment(); break;
        }
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 6;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
示例#7
0
void EmojiWidget::showCategory(const QString &category)
{
    if (scrollArea->widget()->layout()) {
        auto gridLayout = qobject_cast<QGridLayout *>(scrollArea->widget()->layout());
        clearLayout(gridLayout);
        delete gridLayout;
    }

    scrollArea->verticalScrollBar()->setValue(0); // scrool to top

    auto gridLayout = new QGridLayout();
    gridLayout->setContentsMargins(0, 0, 0, 0);
    gridLayout->setHorizontalSpacing(0);
    gridLayout->setVerticalSpacing(0);
    scrollArea->widget()->setLayout(gridLayout);

    int maxCollumns = (width() - scrollArea->verticalScrollBar()->width())/BUTTONS_SIZE;

    QList<Emoji> emojis = emojiManager->getByCategory(category);

    uint index = 0;

    for (const Emoji &emoji : emojis) {
        auto button = new QToolButton();
        button->setIcon(QPixmap(emojiManager->getEmojiIconUrl(emoji)));
        button->setIconSize(QSize(EmojiManager::ICONS_SIZE, EmojiManager::ICONS_SIZE));
        button->setMinimumSize(QSize(EmojiWidget::BUTTONS_SIZE, EmojiWidget::BUTTONS_SIZE));
        QString toolTip = QString(emoji.name).replace(QChar('_'), QString(" "));
        button->setToolTip(toolTip);

        connect(button, &QToolButton::clicked, [=](){
            emojiManager->addRecent(emoji.unifiedCode);

            emit emojiSelected(emoji.unifiedCode);

            recentButton->setEnabled(emojiManager->hasRecents());
        });

        uint row = index / maxCollumns;
        uint collumn = index % maxCollumns;
        gridLayout->addWidget(button, row, collumn, 1, 1, Qt::AlignTop);

        index++;
    }

    scrollArea->widget()->updateGeometry();
    scrollArea->updateGeometry();
}
示例#8
0
SaveGameModule::SaveGameModule(PlayerData& playerData) : playerData(playerData)
{
   setNumberOfColumns(PlayerData::PARTY_SIZE);
   setHorizontalSpacing(10);
   setPadding(5, 5, 5, 5);

   CharacterList party = playerData.getParty();
   for(CharacterList::iterator iter = party.begin(); iter != party.end(); ++iter)
   {
      edwt::Icon* characterPicture = new edwt::Icon((*iter)->getPortraitPath());

      add(characterPicture);
      characterPortraits.push_back(characterPicture);
   }
   
   adjustContent();
   setOpaque(false);
   
   addMouseListener(this);
}