Example #1
0
void QgsOptionsDialogBase::initOptionsBase( bool restoreUi )
{
  // don't add to dialog margins
  // redefine now, or those in inherited .ui file will be added
  if ( layout() )
  {
    layout()->setContentsMargins( 0, 0, 0, 0 ); // Qt default spacing
  }

  // start with copy of qgsoptionsdialog_template.ui to ensure existence of these objects
  mOptListWidget = findChild<QListWidget*>( "mOptionsListWidget" );
  QFrame* optionsFrame = findChild<QFrame*>("mOptionsFrame");
  mOptStackedWidget = findChild<QStackedWidget*>( "mOptionsStackedWidget" );
  mOptSplitter = findChild<QSplitter*>( "mOptionsSplitter" );
  mOptButtonBox = findChild<QDialogButtonBox*>( "buttonBox" );
  QFrame* buttonBoxFrame = findChild<QFrame*>("mButtonBoxFrame");

  if ( !mOptListWidget || !mOptStackedWidget || !mOptSplitter || !optionsFrame )
  {
    return;
  }

  QSettings settings;
  int size = settings.value( "/IconSize", 24 ).toInt();
  mOptListWidget->setIconSize( QSize(size, size) );

  optionsFrame->layout()->setContentsMargins(0,3,3,3);
  QVBoxLayout* layout = static_cast<QVBoxLayout*>(optionsFrame->layout());

  if ( buttonBoxFrame )
  {
      buttonBoxFrame->layout()->setContentsMargins(0,0,0,0);
      layout->insertWidget(layout->count() + 1, buttonBoxFrame );
  }
  else
  {
      layout->insertWidget( layout->count() + 1, mOptButtonBox );
  }

  if ( mOptButtonBox )
  {
    // enforce only one connection per signal, in case added in Qt Designer
    disconnect( mOptButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
    connect( mOptButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
    disconnect( mOptButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
    connect( mOptButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
  }
  connect( mOptSplitter, SIGNAL( splitterMoved( int, int ) ), this, SLOT( updateOptionsListVerticalTabs() ) );
  connect( mOptStackedWidget, SIGNAL( currentChanged( int ) ), this, SLOT( optionsStackedWidget_CurrentChanged( int ) ) );
  connect( mOptStackedWidget, SIGNAL( widgetRemoved( int ) ), this, SLOT( optionsStackedWidget_WidgetRemoved( int ) ) );

  mInit = true;

  if ( restoreUi )
    restoreOptionsBaseUi();
}
bool CTimelineWidget::AddThumbnail(CThumbnailWidget *a_pThumbnail, QWidget* a_pColumn)
{
    QVBoxLayout* pVBLayout = dynamic_cast<QVBoxLayout*>(a_pColumn->layout());
    if (!pVBLayout)
    {
        return false;
    }
    if (pVBLayout->count() == 0)
    {
        pVBLayout->addWidget(a_pThumbnail);
    }
    else if (pVBLayout->count() == 1)
    {
        CThumbnailWidget* pOtherThumbnail = dynamic_cast<CThumbnailWidget*>(pVBLayout->itemAt(0)->widget());
        if (pOtherThumbnail)
        {
            if (a_pThumbnail->GetPlayerID() == CMainWindow::PLAYER_1 && pOtherThumbnail->GetPlayerID() == CMainWindow::PLAYER_2)
            {
                pVBLayout->insertWidget(0, a_pThumbnail);
            }
            else if (a_pThumbnail->GetPlayerID() == CMainWindow::PLAYER_2 && pOtherThumbnail->GetPlayerID() == CMainWindow::PLAYER_1)
            {
                pVBLayout->insertWidget(1, a_pThumbnail);
            }
            else {
                return false;
            }
        }
        else {
            return false;
        }
    }
    else {
        return false;
    }
    if (a_pThumbnail->GetPlayerID() == CMainWindow::PLAYER_1)
    {
        pVBLayout->setAlignment(a_pThumbnail, Qt::AlignTop);
    }
    else if (a_pThumbnail->GetPlayerID() == CMainWindow::PLAYER_2)
    {
        pVBLayout->setAlignment(a_pThumbnail, Qt::AlignBottom);
    }
    else if (a_pThumbnail->GetPlayerID() == CMainWindow::BOTH_PLAYER)
    {
        pVBLayout->setAlignment(a_pThumbnail, Qt::AlignCenter);
    }
    return true;
}
QWidget *PlayerCardDialog::createJudgingArea() {
    QGroupBox *area = new QGroupBox(tr("Judging Area"));
    QVBoxLayout *layout = new QVBoxLayout;
    QList<const Card *> cards = player->getJudgingArea();
    foreach (const Card *card, cards) {
        const Card *real = Sanguosha->getEngineCard(card->getId());
        PlayerCardButton *button = new PlayerCardButton(real->getFullName());
        button->setIcon(G_ROOM_SKIN.getCardSuitPixmap(real->getSuit()));
        layout->addWidget(button);
        button->setEnabled(!disabled_ids.contains(card->getEffectiveId())
                            && (method != Card::MethodDiscard || Self->canDiscard(player, card->getEffectiveId())));
        mapper.insert(button, card->getId());
        connect(button, SIGNAL(clicked()), this, SLOT(emitId()));
    }

    if (layout->count() == 0) {
        PlayerCardButton *button = new PlayerCardButton(tr("No judging cards"));
        button->setEnabled(false);
        button->setObjectName("nojuding_button");
        return button;
    } else {
        area->setLayout(layout);
        return area;
    }
}
void ChannelStripContainer::OnChannelAdded(MixerChannel* channel)
{
    QVBoxLayout* layout = (QVBoxLayout*)this->ui->channelsContent->layout();

    ChannelStripWidget* widget = new ChannelStripWidget(channel);
    layout->insertWidget(layout->count() - 1, widget, 0, Qt::AlignLeft);
}
Example #5
0
void DataSerieDialog::selectRadio(QGroupBox *groupBox, int defaultSelection)
{
    QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(groupBox->layout());
    Q_ASSERT(layout);
    Q_ASSERT(layout->count());

    QLayoutItem *item = 0;
    if (defaultSelection == -1) {
        item = layout->itemAt(0);
    } else if (layout->count() > defaultSelection) {
        item = layout->itemAt(defaultSelection);
    }
    Q_ASSERT(item);
    QRadioButton *radio = qobject_cast<QRadioButton *>(item->widget());
    Q_ASSERT(radio);
    radio->setChecked(true);
}
void MTContactDetails::on_btnAddressAdd_clicked()
{
    QObject * pqobjSender = QObject::sender();

    if (NULL != pqobjSender)
    {
        QPushButton * pBtnAdd = dynamic_cast<QPushButton *>(pqobjSender);

        if (m_pAddresses && (NULL != pBtnAdd))
        {
            QVariant    varContactID   = pBtnAdd->property("contactid");
            QVariant    varMethodCombo = pBtnAdd->property("methodcombo");
            QVariant    varAddressEdit = pBtnAdd->property("addressedit");
            int         nContactID     = varContactID.toInt();
            QComboBox * pCombo         = VPtr<QComboBox>::asPtr(varMethodCombo);
            QLineEdit * pAddressEdit   = VPtr<QLineEdit>::asPtr(varAddressEdit);
            QWidget   * pWidget        = VPtr<QWidget>::asPtr(pBtnAdd->property("methodwidget"));

            if ((nContactID > 0) && (NULL != pCombo) && (NULL != pAddressEdit) && (NULL != pWidget))
            {
                QString qstrMethodType  = QString("");
                QString qstrAddress     = QString("");
                // --------------------------------------------------
                if (pCombo->currentIndex() < 0)
                    return;
                // --------------------------------------------------
                QVariant varMethodType = pCombo->itemData(pCombo->currentIndex());
                qstrMethodType = varMethodType.toString();

                if (qstrMethodType.isEmpty())
                    return;
                // --------------------------------------------------
                qstrAddress = pAddressEdit->text();

                if (qstrAddress.isEmpty())
                    return;
                // --------------------------------------------------
                bool bAdded = MTContactHandler::getInstance()->AddMsgAddressToContact(nContactID, qstrMethodType, qstrAddress);

                if (bAdded) // Let's add it to the GUI, too, then.
                {
                    QString qstrTypeDisplay = pCombo->currentText();
                    // --------------------------------------------------
                    QLayout     * pLayout = m_pAddresses->layout();
                    QVBoxLayout * pVBox   = (NULL == pLayout) ? NULL : dynamic_cast<QVBoxLayout *>(pLayout);

                    if (NULL != pVBox)
                    {
                        QWidget * pNewWidget = this->createSingleAddressWidget(nContactID, qstrMethodType, qstrTypeDisplay, qstrAddress);

                        if (NULL != pNewWidget)
                            pVBox->insertWidget(pVBox->count()-1, pNewWidget);
                    }
                }
            }
        }
    }
}
QWidget *PlayerCardDialog::createEquipArea() {
    QGroupBox *area = new QGroupBox(tr("Equip area"));
    QVBoxLayout *layout = new QVBoxLayout;

    WrappedCard *weapon = player->getWeapon();
    if (weapon) {
        PlayerCardButton *button = new PlayerCardButton(weapon->getFullName());
        button->setIcon(G_ROOM_SKIN.getCardSuitPixmap(Sanguosha->getEngineCard(weapon->getId())->getSuit()));
        button->setEnabled(!disabled_ids.contains(weapon->getEffectiveId())
							&& (method != Card::MethodDiscard || Self->canDiscard(player, weapon->getEffectiveId())));
        mapper.insert(button, weapon->getId());
        connect(button, SIGNAL(clicked()), this, SLOT(emitId()));
        layout->addWidget(button);
    }

    WrappedCard *armor = player->getArmor();
    if (armor) {
        PlayerCardButton *button = new PlayerCardButton(armor->getFullName());
        button->setIcon(G_ROOM_SKIN.getCardSuitPixmap(Sanguosha->getEngineCard(armor->getId())->getSuit()));
        button->setEnabled(!disabled_ids.contains(armor->getEffectiveId())
							&& (method != Card::MethodDiscard || Self->canDiscard(player, armor->getEffectiveId())));
        mapper.insert(button, armor->getId());
        connect(button, SIGNAL(clicked()), this, SLOT(emitId()));
        layout->addWidget(button);
    }

    WrappedCard *horse = player->getDefensiveHorse();
    if (horse) {
        PlayerCardButton *button = new PlayerCardButton(horse->getFullName() + tr("(+1 horse)"));
        button->setIcon(G_ROOM_SKIN.getCardSuitPixmap(Sanguosha->getEngineCard(horse->getId())->getSuit()));
        button->setEnabled(!disabled_ids.contains(horse->getEffectiveId())
							&& (method != Card::MethodDiscard || Self->canDiscard(player, horse->getEffectiveId())));
        mapper.insert(button, horse->getId());
        connect(button, SIGNAL(clicked()), this, SLOT(emitId()));
        layout->addWidget(button);
    }

    horse = player->getOffensiveHorse();
    if (horse) {
        PlayerCardButton *button = new PlayerCardButton(horse->getFullName() + tr("(-1 horse)"));
        button->setIcon(G_ROOM_SKIN.getCardSuitPixmap(Sanguosha->getEngineCard(horse->getId())->getSuit()));
        button->setEnabled(!disabled_ids.contains(horse->getEffectiveId())
							&& (method != Card::MethodDiscard || Self->canDiscard(player, horse->getEffectiveId())));
        mapper.insert(button, horse->getId());
        connect(button, SIGNAL(clicked()), this, SLOT(emitId()));
        layout->addWidget(button);
    }

    if (layout->count() == 0) {
        PlayerCardButton *no_equip = new PlayerCardButton(tr("No equip"));
        no_equip->setEnabled(false);
        no_equip->setObjectName("noequip_button");
        return no_equip;
    } else {
        area->setLayout(layout);
        return area;
    }
}
Example #8
0
void CollapsibleGroup::updateTimecodeFormat()
{
    QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout());
    if (vbox == NULL) return;
    for (int j = vbox->count() - 1; j >= 0; j--) {
	CollapsibleEffect *e = static_cast<CollapsibleEffect *>(vbox->itemAt(j)->widget());
	if (e) e->updateTimecodeFormat();
    }
}
Example #9
0
void tst_QBoxLayout::insertLayout()
{
    QWidget *window = new QWidget;
    QVBoxLayout *vbox = new QVBoxLayout(window);
    QVBoxLayout *dummyParentLayout = new QVBoxLayout;
    QHBoxLayout *subLayout = new QHBoxLayout;
    dummyParentLayout->addLayout(subLayout);
    QCOMPARE(subLayout->parent(), dummyParentLayout);
    QCOMPARE(dummyParentLayout->count(), 1);

    // add subLayout to another layout
    QTest::ignoreMessage(QtWarningMsg, "QLayout::addChildLayout: layout \"\" already has a parent");
    vbox->addLayout(subLayout);
    QCOMPARE((subLayout->parent() == vbox), (vbox->count() == 1));

    delete dummyParentLayout;
    delete window;
}
void SpatialDomainWidget::setSelectedClass(QString ClassName)
{
  QVBoxLayout* Layout = dynamic_cast<QVBoxLayout*>(ui->UnitsClassAreaContents->layout());

  for (int i=0;i<Layout->count();i++)
  {
    if (i!=Layout->count()-1)
    {
      UnitsClassWidget* ClassW = dynamic_cast<UnitsClassWidget*>(Layout->itemAt(i)->widget());

      if (ClassW->getClassName() != ClassName)
        ClassW->setSelected(false);
      else
        ClassW->setSelected(true);
    }
  }

  setActiveClass(ClassName);
}
Example #11
0
QWidget *PlayerCardDialog::createEquipArea(){
    QGroupBox *area = new QGroupBox(tr("Equip area"));
    QVBoxLayout *layout = new QVBoxLayout();

    const Weapon *weapon = player->getWeapon();
    if(weapon){
        QCommandLinkButton *button = new QCommandLinkButton(weapon->getFullName());
        button->setIcon(weapon->getSuitIcon());

        mapper->setMapping(button, weapon->getId());
        connect(button, SIGNAL(clicked()), mapper, SLOT(map()));
        layout->addWidget(button);
    }

    const Armor *armor = player->getArmor();
    if(armor){
        QCommandLinkButton *button = new QCommandLinkButton(armor->getFullName());
        button->setIcon(armor->getSuitIcon());

        mapper->setMapping(button, armor->getId());
        connect(button, SIGNAL(clicked()), mapper, SLOT(map()));
        layout->addWidget(button);
    }

    const Horse *horse = player->getDefensiveHorse();
    if(horse){
        QCommandLinkButton *button = new QCommandLinkButton(horse->getFullName() + tr("(+1 horse)"));
        button->setIcon(horse->getSuitIcon());

        mapper->setMapping(button, horse->getId());
        connect(button, SIGNAL(clicked()), mapper, SLOT(map()));
        layout->addWidget(button);
    }

    horse = player->getOffensiveHorse();
    if(horse){
        QCommandLinkButton *button = new QCommandLinkButton(horse->getFullName() + tr("(-1 horse)"));
        button->setIcon(horse->getSuitIcon());

        mapper->setMapping(button, horse->getId());
        connect(button, SIGNAL(clicked()), mapper, SLOT(map()));
        layout->addWidget(button);
    }

    if(layout->count() == 0){
        QCommandLinkButton *no_equip = new QCommandLinkButton(tr("No equip"));
        no_equip->setEnabled(false);
        return no_equip;
    }else{
        area->setLayout(layout);
        return area;
    }
}
EDFViewerWindow::EDFViewerWindow(QWidget *parent)
    : QWidget(parent){
    QVBoxLayout *vb;
    QHBoxLayout *hb;
    QMenu *menu;
    QAction *act;
    QMenuBar* menuBar;

    vb=new QVBoxLayout();
    hb=new QHBoxLayout();
    vb->addLayout(hb);
    menuBar = new QMenuBar();
    menu= menuBar->addMenu(tr("&File"));
    act=new QAction(tr("&Open"), this);
    menu->addAction(act);
    connect(act, SIGNAL(triggered()), this, SLOT(fileOpen()));
    act=new QAction(tr("&Exit"), this);
    connect(act, SIGNAL(triggered()), this, SLOT(close()));
    menu->addAction(act);
    menu= menuBar->addMenu(tr("&EDF"));
    act=new QAction(tr("&EDF Data"), this);
    menu->addAction(act);
    QObject::connect(act,&QAction::triggered,datawindow);
    act=new QAction(tr("&Signals"), this);
    menu->addAction(act);
    QObject::connect(act,&QAction::triggered,signalswindow);
    hb->addWidget(menuBar);
    hb->setStretch(hb->count()-1,1);
    menuBar = new QMenuBar();
    menu= menuBar->addMenu(tr("&Help"));
    act=new QAction(tr("&About"), this);
    menu->addAction(act);
    QObject::connect(act,&QAction::triggered,aboutwindow);
    hb->addWidget(menuBar);

    vb->addWidget(paintWidget=new PaintWidget());
    vb->setStretch(vb->count()-1,1);
    hScrollBar = new QScrollBar(Qt::Horizontal, this);
    connect(hScrollBar, SIGNAL(valueChanged(int)),this,SLOT(changehbar(int)));
    hb=new QHBoxLayout();
    hb->addWidget(hScrollBar);
    hb->setStretch(hb->count()-1,1);
    le1=new QLineEdit();
    le1->setText("4");
    le1->setFixedSize(32,16);
    hb->addWidget(le1);
    connect(le1, SIGNAL(textChanged(const QString &)), this, SLOT(screentimechanged(const QString &)));
    hb->addWidget(new QLabel("sec"));
    vb->addLayout(hb);
    resize(450,400);
    setLayout(vb);
}
ChannelStripWidget* ChannelStripContainer::GetWidgetByChannel(MixerChannel* channel)
{
    QVBoxLayout* layout = (QVBoxLayout*)this->ui->channelsContent->layout();

    for (int i = 0; i < layout->count(); i++)
    {
        ChannelStripWidget* widget = dynamic_cast<ChannelStripWidget*>(layout->itemAt(i)->widget());
        if (widget != 0 && widget->GetChannel() == channel)
            return widget;
    }

    return 0;
}
void DlgImportCroppingNonPdf::finishPanel (QWidget *subPanel)
{
  const int STRETCH_OFF = 0, STRETCH_ON = 1;

  QVBoxLayout *panelLayout = new QVBoxLayout (this);

  setMinimumWidth (MINIMUM_DIALOG_WIDTH);
  setLayout (panelLayout);

  panelLayout->addWidget (subPanel);
  panelLayout->setStretch (panelLayout->count () - 1, STRETCH_ON);

  QWidget *panelButtons = new QWidget (this);
  QHBoxLayout *buttonLayout = new QHBoxLayout (panelButtons);

  QHBoxLayout *layoutRightSide = new QHBoxLayout;

  QWidget *widgetRightSide = new QWidget;
  widgetRightSide->setLayout (layoutRightSide);
  buttonLayout->addWidget (widgetRightSide);

  QSpacerItem *spacerExpanding = new QSpacerItem (40, 5, QSizePolicy::Expanding, QSizePolicy::Expanding);
  layoutRightSide->addItem (spacerExpanding);

  m_btnOk = new QPushButton (tr ("Ok"));
  layoutRightSide->addWidget (m_btnOk, 0, Qt::AlignRight);
  connect (m_btnOk, SIGNAL (released ()), this, SLOT (slotOk ()));

  QSpacerItem *spacerFixed = new QSpacerItem (40, 5, QSizePolicy::Fixed, QSizePolicy::Fixed);
  layoutRightSide->addItem (spacerFixed);

  m_btnCancel = new QPushButton (tr ("Cancel"));
  layoutRightSide->addWidget (m_btnCancel, 0, Qt::AlignRight);
  connect (m_btnCancel, SIGNAL (released ()), this, SLOT (slotCancel ()));

  panelLayout->addWidget (panelButtons, STRETCH_ON);
  panelLayout->setStretch (panelLayout->count () - 1, STRETCH_OFF);
}
Example #15
0
void FormResizer::setFormWindow(QDesignerFormWindowInterface *fw)
{
    if (debugFormResizer)
        qDebug() << "FormResizer::setFormWindow " << fw;
    QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(m_frame->layout());
    Q_ASSERT(layout);
    if (layout->count())
        delete layout->takeAt(0);
    m_formWindow = fw;

    if (m_formWindow)
        layout->addWidget(m_formWindow);
    mainContainerChanged();
     connect(fw, SIGNAL(mainContainerChanged(QWidget*)), this, SLOT(mainContainerChanged()));
}
void LayoutAliasEditDialog::addAlias() {

    QPushButton * src = (QPushButton *) sender();

    QVBoxLayout * contentLayout = (QVBoxLayout *) src->property("layout").value<void *>();

    srcNineMLLayout->AliasList.push_back(new Alias());
    srcNineMLLayout->AliasList.back()->name = "newAlias";
    srcNineMLLayout->AliasList.back()->maths = new MathInLine;
    srcNineMLLayout->AliasList.back()->maths->equation = "0";

    // add new Alias to display
    contentLayout->insertLayout(contentLayout->count() - 3, drawAlias(srcNineMLLayout->AliasList.back()));

}
Example #17
0
void FluushOption::FileListSent(QList<FluushFileInfo> &list)
{
    QVBoxLayout *lay = ui->history;

    for(int i  = 0 ; i < lay->count() ; i++)
    {
        QWidget* it = lay->itemAt(i)->widget();
        lay->removeWidget(it);
        it->deleteLater();
    }

    for(QList<FluushFileInfo>::iterator i = list.begin() ; i != list.end() ; i++)
    {
        ThumbWidget *wid= new ThumbWidget(ui->apiKey->text(), (*i).id, (*i).url, (*i).name, net, this);
        lay->addWidget(wid);
    }
}
Example #18
0
QString DataSerieDialog::radioSelection(QGroupBox *groupBox)
{
    QString selection;
    QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(groupBox->layout());
    Q_ASSERT(layout);

    for (int i(0); i < layout->count(); i++) {
        QLayoutItem *item = layout->itemAt(i);
        Q_ASSERT(item);
        QRadioButton *radio = qobject_cast<QRadioButton *>(item->widget());
        Q_ASSERT(radio);
        if (radio->isChecked()) {
            selection = radio->text();
            break;
        }
    }

    qDebug() << "radioSelection: " << selection;
    return selection;
}
QnxAttachDebugDialog::QnxAttachDebugDialog(ProjectExplorer::KitChooser *kitChooser, QWidget *parent)
    : ProjectExplorer::DeviceProcessesDialog(kitChooser, parent)
{
    QVBoxLayout *mainLayout = dynamic_cast<QVBoxLayout*>(layout());
    QTC_ASSERT(mainLayout, return);

    QFormLayout *formLayout = new QFormLayout;

    QLabel *sourceLabel = new QLabel(tr("Project source directory:"), this);
    m_projectSource = new Utils::PathChooser(this);
    m_projectSource->setExpectedKind(Utils::PathChooser::ExistingDirectory);
    formLayout->addRow(sourceLabel, m_projectSource);

    QLabel *binaryLabel = new QLabel(tr("Local executable:"), this);
    m_localExecutable = new Utils::PathChooser(this);
    m_localExecutable->setExpectedKind(Utils::PathChooser::File);
    formLayout->addRow(binaryLabel, m_localExecutable);

    mainLayout->insertLayout(mainLayout->count() - 2, formLayout);
}
void QgsOptionsDialogBase::initOptionsBase( bool restoreUi, QString title )
{
  // use pointer to app QSettings if no custom QSettings specified
  // custom QSettings object may be from Python plugin
  mDelSettings = false;

  if ( !mSettings )
  {
    mSettings = new QSettings();
    mDelSettings = true; // only delete obj created by class
  }

  // save dialog title so it can be used to be concatenated
  // with category title in icon-only mode
  if ( title.isEmpty() )
    mDialogTitle = windowTitle();
  else
    mDialogTitle = title;

  // don't add to dialog margins
  // redefine now, or those in inherited .ui file will be added
  if ( layout() )
  {
    layout()->setContentsMargins( 0, 0, 0, 0 ); // Qt default spacing
  }

  // start with copy of qgsoptionsdialog_template.ui to ensure existence of these objects
  mOptListWidget = findChild<QListWidget*>( "mOptionsListWidget" );
  QFrame* optionsFrame = findChild<QFrame*>( "mOptionsFrame" );
  mOptStackedWidget = findChild<QStackedWidget*>( "mOptionsStackedWidget" );
  mOptSplitter = findChild<QSplitter*>( "mOptionsSplitter" );
  mOptButtonBox = findChild<QDialogButtonBox*>( "buttonBox" );
  QFrame* buttonBoxFrame = findChild<QFrame*>( "mButtonBoxFrame" );

  if ( !mOptListWidget || !mOptStackedWidget || !mOptSplitter || !optionsFrame )
  {
    return;
  }

  int size = mSettings->value( "/IconSize", 24 ).toInt();
  // buffer size to match displayed icon size in toolbars, and expected geometry restore
  // newWidth (above) may need adjusted if you adjust iconBuffer here
  int iconBuffer = 4;
  mOptListWidget->setIconSize( QSize( size + iconBuffer, size + iconBuffer ) );
  mOptListWidget->setFrameStyle( QFrame::NoFrame );

  optionsFrame->layout()->setContentsMargins( 0, 3, 3, 3 );
  QVBoxLayout* layout = static_cast<QVBoxLayout*>( optionsFrame->layout() );

  if ( buttonBoxFrame )
  {
    buttonBoxFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
    layout->insertWidget( layout->count() + 1, buttonBoxFrame );
  }
  else
  {
    layout->insertWidget( layout->count() + 1, mOptButtonBox );
  }

  if ( mOptButtonBox )
  {
    // enforce only one connection per signal, in case added in Qt Designer
    disconnect( mOptButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
    connect( mOptButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
    disconnect( mOptButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
    connect( mOptButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
  }
  connect( mOptSplitter, SIGNAL( splitterMoved( int, int ) ), this, SLOT( updateOptionsListVerticalTabs() ) );
  connect( mOptStackedWidget, SIGNAL( currentChanged( int ) ), this, SLOT( optionsStackedWidget_CurrentChanged( int ) ) );
  connect( mOptStackedWidget, SIGNAL( widgetRemoved( int ) ), this, SLOT( optionsStackedWidget_WidgetRemoved( int ) ) );

  mInit = true;

  if ( restoreUi )
    restoreOptionsBaseUi( mDialogTitle );
}
void SpatialDomainWidget::refresh()
{
  // -------- prepare classes list --------

  QStringList OriginalClassesList = openfluid::tools::toQStringList(m_Domain.getClassNames());

  QStringList ClassesList;

  // get display order for classes from project config file
  QVariant TmpList =
      openfluid::base::ProjectManager::instance()->getConfigValue("builder.spatial.unitsclasses","order");

  if (!TmpList.isValid())
  {
    openfluid::base::ProjectManager::instance()->setConfigValue("builder.spatial.unitsclasses","order",
                                                                OriginalClassesList);
    ClassesList = OriginalClassesList;
  }
  else
  {
    ClassesList = TmpList.toStringList();

    // find classes in project config file that are not in original dataset
    QStringList ClassesToRemove;
    for (int i=0; i< ClassesList.size();i++)
    {
      if (!OriginalClassesList.contains(ClassesList[i]))
        ClassesToRemove.append(ClassesList[i]);
    }

    // remove them from classes to display
    for (int i=0; i< ClassesToRemove.size();i++)
      ClassesList.removeAll(ClassesToRemove[i]);

    // remove classes from original list if they exists in classes to display
    for (int i=0; i< ClassesList.size();i++)
    {
      if (OriginalClassesList.contains(ClassesList[i]))
        OriginalClassesList.removeAll(ClassesList[i]);
    }

    // add original dataset classes that are not already in the classes to display
    for (int i=0; i< OriginalClassesList.size();i++)
    {
      if (!ClassesList.contains(OriginalClassesList[i]))
        ClassesList.append(OriginalClassesList[i]);
    }

    openfluid::base::ProjectManager::instance()->setConfigValue("builder.spatial.unitsclasses","order",ClassesList);
  }


  // -------- display classes widgets ---------

  // remove classes from display that does not exist anymore

  QVBoxLayout* Layout = dynamic_cast<QVBoxLayout*>(ui->UnitsClassAreaContents->layout());

  // search for classes to remove from layout
  QList<int> ItemsToRemove;

  for (int j=0;j<Layout->count();j++)
  {
    if (Layout->itemAt(j)->widget() != NULL)
    {

      UnitsClassWidget* ClassW = dynamic_cast<UnitsClassWidget*>(Layout->itemAt(j)->widget());

      if (!ClassesList.contains(ClassW->getClassName()))
      {
        if (ClassW->getClassName() == m_ActiveClass)
          m_ActiveClass = "";

        ItemsToRemove.append(j);
      }
    }
  }

  // effectively remove classes from layout
  QListIterator<int> itTR(ItemsToRemove);
  itTR.toBack();
  while (itTR.hasPrevious())
    Layout->takeAt(itTR.previous())->widget()->deleteLater();


  // Add of new classes to layout
  for (int i = 0; i<ClassesList.size(); i++)
  {
    bool AlreadyExist = false;

    // searching for already existing unit class in class list
    for (int j=0;j<Layout->count();j++)
    {
      if (j!=Layout->count()-1)
      {
        UnitsClassWidget* ClassW = dynamic_cast<UnitsClassWidget*>(Layout->itemAt(j)->widget());

        if (ClassW->getClassName() == ClassesList[i])
          AlreadyExist = true;
      }
    }

    // Add if it does not already exist
    if (!AlreadyExist)
    {
      UnitsClassWidget* ClassW =
          new UnitsClassWidget(ClassesList[i],
                               m_Datastore.getItems(ClassesList[i].toStdString(),
                                                    openfluid::core::UnstructuredValue::GeoVectorValue),
                               ui->UnitsClassAreaContents);

      dynamic_cast<QVBoxLayout*>(ui->UnitsClassAreaContents->layout())->insertWidget(Layout->count()-1,ClassW);
      connect(ClassW,SIGNAL(selectionRequested(QString)),this,SLOT(setSelectedClass(QString)));
      connect(ClassW,SIGNAL(styleChanged(QString)),this,SLOT(refreshMap()));
      connect(ClassW,SIGNAL(upClicked(QString)),this,SLOT(moveUnitsClassUp(QString)));
      connect(ClassW,SIGNAL(downClicked(QString)),this,SLOT(moveUnitsClassDown(QString)));
      connect(ClassW,SIGNAL(removeClicked(QString)),this,SLOT(removeUnitsClass(QString)));
    }
  }


  if (m_ActiveClass.isEmpty())
  {
    // active class is not defined, pick the first units class if any
    if (Layout->count()>1)
      setSelectedClass(dynamic_cast<UnitsClassWidget*>(Layout->itemAt(0)->widget())->getClassName());
    else
      setActiveClass("");
  }
  else
  {
    setSelectedClass(m_ActiveClass);
  }

  refreshMap();
}
Example #22
0
void PointPropertyView::updateProperty(Member *m, const QByteArray &array)
{
    MatrixEdit *e = findChild<MatrixEdit*>(QLatin1String("inputLoads"));
    QVBoxLayout *v = findChild<QVBoxLayout*>(QLatin1String("index"));
    QVBoxLayout *u = findChild<QVBoxLayout*>(QLatin1String("insert"));
    QVBoxLayout *w = findChild<QVBoxLayout*>(QLatin1String("remove"));
    if (array.startsWith('i'))
    {
        e->insertRow(array.right(array.size()-1).toInt());
        for (int i=0;i<6;++i)
            e->setText(array.right(array.size()-1).toInt(),i,QString::number(static_cast<Point*>(m)->loads.at(array.right(array.size()-1).toInt())[i]));
        v->addWidget(new QLabel(QString::number(v->count()+1).prepend(QLatin1String("No."))));
        static_cast<QLabel*>(v->itemAt(v->count()-1)->widget())->setFrameShape(QFrame::StyledPanel);
        u->addWidget(new QToolButton);
        static_cast<QToolButton*>(u->itemAt(u->count()-1)->widget())->setText(QLatin1String("+"));
        connect(u->itemAt(u->count()-1)->widget(),SIGNAL(clicked()),SLOT(addLoad()));
        w->addWidget(new QToolButton);
        static_cast<QToolButton*>(w->itemAt(w->count()-1)->widget())->setText(QLatin1String("-"));
        connect(w->itemAt(w->count()-1)->widget(),SIGNAL(clicked()),SLOT(removeLoad()));
    }
    else if (array.startsWith('r'))
    {
        e->removeRow(array.right(array.size()-1).toInt());
        delete v->takeAt(v->count()-1)->widget();
        delete u->takeAt(u->count()-1)->widget();
        delete w->takeAt(w->count()-1)->widget();
    }
    else if (array.startsWith('s'))
    {
        e->insertColumns(0,6);
        e->insertRows(0,static_cast<Point*>(m)->loads.size());
        for (int i=0,j;i<static_cast<Point*>(m)->loads.size();)
        {
            for (j=0;j<6;++j)
                e->setText(i,j,QString::number(static_cast<Point*>(m)->loads.at(i)[j]));
            u->addWidget(new QToolButton);
            static_cast<QToolButton*>(u->itemAt(i)->widget())->setText(QLatin1String("+"));
            connect(u->itemAt(i)->widget(),SIGNAL(clicked()),SLOT(addLoad()));
            w->addWidget(new QToolButton);
            static_cast<QToolButton*>(w->itemAt(w->count()-1)->widget())->setText(QLatin1String("-"));
            connect(w->itemAt(w->count()-1)->widget(),SIGNAL(clicked()),SLOT(removeLoad()));
            v->addWidget(new QLabel(QString::number(++i).prepend(QLatin1String("No."))));
            static_cast<QLabel*>(v->itemAt(i-1)->widget())->setFrameShape(QFrame::StyledPanel);
        }
    }
    else
        e->setText(array.split(' ').first().toInt(),array.split(' ').last().toInt(),QString::number(static_cast<Point*>(m)->loads.at(array.split(' ').first().toInt())[array.split(' ').last().toInt()]));
}
Example #23
0
NPreferencesDialog::NPreferencesDialog(QWidget *parent) : QDialog(parent)
{
    ui.setupUi(this);

    connect(ui.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(saveSettings()));
    connect(this, SIGNAL(accepted()), this, SLOT(saveSettings()));
    ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Ok"));
    ui.buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
    ui.buttonBox->button(QDialogButtonBox::Apply)->setText(tr("Apply"));

    connect(ui.singleInstanceCheckBox, SIGNAL(toggled(bool)), ui.enqueueFilesCheckBox, SLOT(setEnabled(bool)));
    connect(ui.enqueueFilesCheckBox, SIGNAL(toggled(bool)), ui.playEnqueuedCheckBox, SLOT(setEnabled(bool)));
    connect(ui.singleInstanceCheckBox, SIGNAL(toggled(bool)), ui.playEnqueuedCheckBox, SLOT(setEnabled(bool)));
    connect(ui.restorePlaylistCheckBox, SIGNAL(toggled(bool)), ui.startPausedCheckBox, SLOT(setEnabled(bool)));
    connect(ui.customFileManagerCheckBox, SIGNAL(toggled(bool)), ui.customFileManagerCommandLineEdit, SLOT(setEnabled(bool)));
    connect(ui.customTrashCheckBox, SIGNAL(toggled(bool)), ui.customTrashCommandLineEdit, SLOT(setEnabled(bool)));

    setWindowTitle(QCoreApplication::applicationName() + tr(" Preferences"));

#ifdef _N_NO_SKINS_
    ui.skinLabel->hide();
    ui.skinComboBox->hide();
#endif

#ifndef Q_WS_WIN
    ui.taskbarProgressContainer->hide();
#endif

#ifdef _N_NO_UPDATE_CHECK_
    ui.autoCheckUpdatesContainer->hide();
#endif

#if defined Q_WS_WIN || defined Q_WS_MAC
    ui.customTrashContainer->hide();
#endif

    QPixmap pixmap = QIcon::fromTheme("dialog-warning", style()->standardIcon(QStyle::SP_MessageBoxWarning)).pixmap(16);
    QByteArray byteArray;
    QBuffer buffer(&byteArray);
    pixmap.save(&buffer, "PNG");
    NSkinFileSystem::addFile("warning.png", byteArray);
    QString url = "<img src=\"skin:warning.png\"/>";

    QVBoxLayout *scrollLayout = new QVBoxLayout;
    ui.pluginsScrollArea->widget()->setLayout(scrollLayout);

    NFlagIterator<N::PluginType> iter(N::MaxPlugin);
    while (iter.hasNext()) {
        iter.next();
        N::PluginType type = iter.value();
        QGroupBox *groupBox = createGroupBox(type);
        if (groupBox)
            scrollLayout->addWidget(groupBox);
    }

    if (scrollLayout->count() > 0)
        scrollLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Expanding));
    else
        ui.tabWidget->removeTab(ui.tabWidget->indexOf(ui.pluginsTab));

    ui.pluginsRestartLabel->setText(url + "&nbsp;&nbsp;" + ui.pluginsRestartLabel->text());
    ui.pluginsRestartLabel->setVisible(false);

    ui.languageRestartLabel->setText(url + "&nbsp;&nbsp;" + ui.languageRestartLabel->text());
    ui.languageRestartLabel->setVisible(false);

    ui.skinRestartLabel->setText(url + "&nbsp;&nbsp;" + ui.skinRestartLabel->text());
    ui.skinRestartLabel->setVisible(false);
    connect(ui.skinComboBox, SIGNAL(activated(int)), ui.skinRestartLabel, SLOT(show()));

    ui.waveformTrackInfoTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);

    int i = 0;
    foreach (int mib, QTextCodec::availableMibs()) {
        QString codecName = QTextCodec::codecForMib(mib)->name();
        ui.encodingTrackInfoComboBox->addItem(codecName, mib);
        if (codecName == "UTF-8")
            ui.encodingTrackInfoComboBox->setCurrentIndex(i);
        ++i;
    }
void GameWidgetScrollArea::resizeEvent(QResizeEvent * event) {
	int widgetWidth = GameChoiceWidget::getWidgetWidth();
	int widgetsPerRowNew = event->size().width() / widgetWidth;

	if (widgetsPerRowNew <= 0) {
		fprintf(stderr, "Error: window too small. Exiting.\n");
		static GameController* instance = GameController::acquire();
		instance->terminateApplication();
	}

	if (widgetsPerRowNew < m_widgetsPerRow) {
		// too many widgets per row, must make rows shorter

		QVBoxLayout* overallLayout = (QVBoxLayout*) this->widget()->layout();

		int numToMove = m_widgetsPerRow - widgetsPerRowNew;
		for (int i = 0; i < overallLayout->count() - 1 && numToMove > 0; ++i) {
			QHBoxLayout* horizontalRow =
					(QHBoxLayout*) overallLayout->itemAt(i)->layout();
			QHBoxLayout* nextHorizontalRow;
			for (int j = 0; j < numToMove; ++j) {
				QWidget* lastWidget = horizontalRow->itemAt(
						horizontalRow->count() - 2)->widget();
				horizontalRow->removeWidget(lastWidget);

				if (i == overallLayout->count() - 2) {
					QHBoxLayout* newRow = new QHBoxLayout();
					newRow->addStretch(ms_stretchFactor);
					overallLayout->insertLayout(overallLayout->count() - 1,
							newRow);
				}

				nextHorizontalRow =
						(QHBoxLayout*) overallLayout->itemAt(i + 1)->layout();
				nextHorizontalRow->insertWidget(0, lastWidget, 0,
						Qt::AlignLeading);
			}

			numToMove = nextHorizontalRow->count() - widgetsPerRowNew - 1;
		}

		m_widgetsPerRow = std::min(widgetsPerRowNew, m_totalNumberGameWidgets);
	} else if (m_widgetsPerRow < m_totalNumberGameWidgets
			&& widgetsPerRowNew > m_widgetsPerRow) {
		// add widgets to each row to make each longer and have less rows

		QVBoxLayout* overallLayout = (QVBoxLayout*) this->widget()->layout();

		int numToMove = widgetsPerRowNew - m_widgetsPerRow;

		QHBoxLayout* currentHorizontalRow =
				(QHBoxLayout*) overallLayout->itemAt(0)->layout();
		for (int i = 1; i < overallLayout->count() - 1; ++i) {
			QHBoxLayout* nextHorizontalRow =
					(QHBoxLayout*) overallLayout->itemAt(i)->layout();

			for (int j = 0; j < numToMove; ++j) {
				if (nextHorizontalRow->count() <= 1) {
					if (i == overallLayout->count() - 2) {
						overallLayout->removeItem(overallLayout->itemAt(i));
						break;
					}
					overallLayout->removeItem(overallLayout->itemAt(i));
					nextHorizontalRow =
							(QHBoxLayout*) overallLayout->itemAt(i)->layout();
				}
				QWidget* firstWidget = nextHorizontalRow->itemAt(0)->widget();
				nextHorizontalRow->removeWidget(firstWidget);
				currentHorizontalRow->insertWidget(
						currentHorizontalRow->count() - 1, firstWidget);
			}

			currentHorizontalRow = nextHorizontalRow;

			numToMove = widgetsPerRowNew - (nextHorizontalRow->count() - 1);
		}

		m_widgetsPerRow = std::min(widgetsPerRowNew, m_totalNumberGameWidgets);
	}

	QWidget* content = this->widget();
	content->resize(this->width(), content->sizeHint().height());
}
Example #25
0
void AlgorithmRunner::insertItem(QWidget *w, const QString &name) {

  const Plugin &plugin = PluginLister::pluginInformation(QStringToTlpString(name));
  QString category = plugin.category().c_str();
  QString group = plugin.group().c_str();

  ExpandableGroupBox *categoryBox = nullptr, *groupBox = nullptr;

  for (auto box : w->findChildren<ExpandableGroupBox *>()) {
    if (box->objectName() == category) {
      categoryBox = box;
      break;
    }
  }

  if (categoryBox == nullptr)
    return;

  if (!group.isEmpty()) {
    for (auto box : categoryBox->findChildren<ExpandableGroupBox *>()) {
      if (box->objectName() == group) {
        groupBox = box;
        break;
      }
    }
  }

  if (!group.isEmpty() && groupBox == nullptr) {
    groupBox = createGroupBox(group);
    QVBoxLayout *categoryLayout = static_cast<QVBoxLayout *>(categoryBox->widget()->layout());
    int index = 0;

    while (index < categoryLayout->count()) {
      ExpandableGroupBox *gb =
          dynamic_cast<ExpandableGroupBox *>(categoryLayout->itemAt(index)->widget());

      if (gb && group < gb->title()) {
        break;
      }

      ++index;
    }

    categoryLayout->insertWidget(index, groupBox);
  } else {
    groupBox = categoryBox;
  }

  AlgorithmRunnerItem *item = new AlgorithmRunnerItem(name);
  QObject::connect(this, SIGNAL(setStoreResultAsLocal(bool)), item,
                   SLOT(setStoreResultAsLocal(bool)));
  QObject::connect(item, SIGNAL(favorized(bool)), this, SLOT(favorized(bool)));
  QVBoxLayout *groupLayout = static_cast<QVBoxLayout *>(groupBox->widget()->layout());
  int index = 0;

  while (index < groupLayout->count()) {
    AlgorithmRunnerItem *i =
        dynamic_cast<AlgorithmRunnerItem *>(groupLayout->itemAt(index)->widget());

    if (i && name < i->name()) {
      break;
    }

    ++index;
  }

  groupLayout->insertWidget(index, item);
}
Example #26
0
void ScoreBrowser::setScores(QFileInfoList& s)
      {
      qDeleteAll(scoreLists);
      scoreLists.clear();

      QVBoxLayout* l = static_cast<QVBoxLayout*>(scoreList->layout());
      while (l->count())
            l->removeItem(l->itemAt(0));

      ScoreListWidget* sl = 0;

      QStringList filter = { "*.mscz" };

      if (_showCustomCategory)
            std::sort(s.begin(), s.end(), [](QFileInfo a, QFileInfo b)->bool { return a.fileName() < b.fileName(); });

      QSet<QString> entries; //to avoid duplicates
      for (const QFileInfo& fi : s) {
            if (fi.isDir()) {
                  QString s(fi.fileName());
                  if (!s.isEmpty() && s[0].isNumber() && _stripNumbers)
                        s = s.mid(3);
                  s = s.replace('_', ' ');
                  QLabel* label = new QLabel(s);
                  QFont f = label->font();
                  f.setBold(true);
                  label->setFont(f);
                  static_cast<QVBoxLayout*>(l)->addWidget(label);
                  QDir dir(fi.filePath());
                  sl = createScoreList();
                  l->addWidget(sl);
                  unsigned count = 0; //nbr of entries added
                  for (const QFileInfo& fi : dir.entryInfoList(filter, QDir::Files, QDir::Name)){
                        if (entries.contains(fi.filePath()))
                            continue;
                        sl->addItem(genScoreItem(fi, sl));
                        count++;
                        entries.insert(fi.filePath());
                        }
                  if (count == 0) {
                        delete label;
                        delete sl;
                        }
                  sl = 0;
                  }
            }
      for (const QFileInfo& fi : s) {
            if (fi.isFile()) {
                  QString s = fi.filePath();
                  if (entries.contains(s))
                      continue;
                  if (s.endsWith(".mscz") || s.endsWith(".mscx")) {
                        if (!sl) {
                              if (_showCustomCategory) {
                                    QLabel* label = new QLabel(tr("Custom Templates"));
                                    QFont f = label->font();
                                    f.setBold(true);
                                    label->setFont(f);
                                    l->insertWidget(2,label);
                                    }
                              sl = createScoreList();
                              l->insertWidget(3,sl);
                              }
                        sl->addItem(genScoreItem(fi, sl));
                        entries.insert(s);
                        }
                  }
            }
      }