Exemplo n.º 1
0
QWidget * ExtArgRadio::createEditor(QWidget * parent)
{

    int count = 0;
    bool anyChecked = false;

    selectorGroup = new QButtonGroup(parent);
    QWidget * radioButtons = new QWidget;
    QVBoxLayout * vrLayout = new QVBoxLayout();
    QMargins margins = vrLayout->contentsMargins();
    vrLayout->setContentsMargins(0, 0, 0, margins.bottom());
    if ( callStrings != 0 )
        delete callStrings;

    callStrings = new QList<QString>();

    if ( values.length() > 0  )
    {
        ExtcapValueList::const_iterator iter = values.constBegin();

        while ( iter != values.constEnd() )
       {
            QRadioButton * radio = new QRadioButton((*iter).value());
            QString callString = (*iter).call();
            callStrings->append(callString);

            if ( _default != NULL && (*iter).isDefault() )
            {
                radio->setChecked(true);
                anyChecked = true;
            }
            else if (_default != NULL)
            {
                if ( callString.compare(_default->toString()) == 0 )
                {
                    radio->setChecked(true);
                    anyChecked = true;
                }
            }

            connect(radio, SIGNAL(clicked(bool)), SLOT(onBoolChanged(bool)));
            selectorGroup->addButton(radio, count);

            vrLayout->addWidget(radio);
            count++;

            ++iter;
        }
    }

    /* No default was provided, and not saved value exists */
    if ( anyChecked == false && count > 0 )
        ((QRadioButton*)(selectorGroup->button(0)))->setChecked(true);

    radioButtons->setLayout(vrLayout);

    return radioButtons;
}
Exemplo n.º 2
0
void SettingsWidget::updateAddresses(const Protos::Common::Interface& interfaceMess, QWidget* container)
{
    QVBoxLayout* layout = container->findChild<QVBoxLayout*>();
    if (!layout)
    {
        layout = new QVBoxLayout(container);
        QMargins margins = layout->contentsMargins();
        margins.setTop(3);
        layout->setContentsMargins(margins);
    }

    QList<QRadioButton*> addressesNotUpdated = container->findChildren<QRadioButton*>();

    for (int i = 0; i < interfaceMess.address_size(); i++)
    {
        const QString& addresseName = Common::ProtoHelper::getStr(interfaceMess.address(i), &Protos::Common::Interface::Address::address);

        for (QListIterator<QRadioButton*> j(container->findChildren<QRadioButton*>()); j.hasNext();)
        {
            QRadioButton* addressButton = j.next();
            if (addressButton->text() == addresseName)
            {
                addressesNotUpdated.removeOne(addressButton);
                if (interfaceMess.address(i).listened())
                    addressButton->setChecked(true);
                goto nextAddress;
            }
        }

        {
            // Address not found -> add a new one.
            QRadioButton* newAddressButton = new QRadioButton(addresseName, container);
            this->ui->grpAddressesToListenTo->addButton(newAddressButton);
            if (interfaceMess.address(i).listened())
                newAddressButton->setChecked(true);
            layout->addWidget(newAddressButton);
        }

nextAddress:
        ;
    }

    // Remove the non-existant addresses.
    for (QListIterator<QRadioButton*> i(container->findChildren<QRadioButton*>()); i.hasNext();)
    {
        QRadioButton* current = i.next();
        if (addressesNotUpdated.contains(current))
        {
            layout->removeWidget(current);
            this->ui->grpAddressesToListenTo->removeButton(current);
            delete current;
        }
    }
}
Exemplo n.º 3
0
WBigBmpGraphicsView::WBigBmpGraphicsView(QWidget *parent)
	: WGraphicsView(parent)
{
	pixelInfoLabel = new WDecoratedSimpleLabel();
	QFont font = pixelInfoLabel->font();
	QString family = font.family();
	font.setPixelSize(20);
	font.setBold(true);
	pixelInfoLabel->setFont(font);
	pixelInfoLabel->showAlways(true);

	renderStatus = new WDecoratedSimpleLabel();
	renderStatus->setFont(font);
	renderStatus->setText("");
	renderStatus->setBorderPen(QPen(Qt::black, 0.5));
	renderStatus->setFillBrush(QBrush(Qt::red));

	renderProgress = new WTransparentProgressBar;
	renderProgress->setOpacity(0.0);
	renderProgress->setFormat(tr("Caching %p%"));

	QHBoxLayout* topLayout = new QHBoxLayout;
	topLayout->addWidget(pixelInfoLabel);
	topLayout->addStretch(1);

	QHBoxLayout* bottomLayout = new QHBoxLayout;
	bottomLayout->addWidget(renderProgress, 1);
	bottomLayout->addStretch(1);
	bottomLayout->addWidget(renderStatus);

	QVBoxLayout* layout = new QVBoxLayout;
	layout->addLayout(topLayout);
	layout->addStretch(1);
	layout->addLayout(bottomLayout);

	QMargins margins = layout->contentsMargins();
	int r = margins.right();
	int hw = horizontalScrollBar()->sizeHint().width() / 2;
	margins.setRight( r + hw );
	int b = margins.bottom();
	int vh = verticalScrollBar()->sizeHint().height() / 2;
	margins.setBottom( b + vh );
	layout->setContentsMargins(margins);
	setLayout(layout);
}
// //! [CustomViewerWorkbenchWindowAdvisorPreWindowOpen]
// //! [WorkbenchWindowAdvisorCreateWindowContentsHead]
void CustomViewerWorkbenchWindowAdvisor::CreateWindowContents(berry::Shell::Pointer shell)
{
  //the all containing main window
  QMainWindow* mainWindow = static_cast<QMainWindow*>(shell->GetControl());
// //! [WorkbenchWindowAdvisorCreateWindowContentsHead]
  mainWindow->setVisible(true);

  //the widgets
  QWidget* CentralWidget = new QWidget(mainWindow);
  CentralWidget->setObjectName("CentralWidget");
  CentralWidget->setVisible(true);

  QtPerspectiveSwitcherTabBar* PerspectivesTabBar = new QtPerspectiveSwitcherTabBar(this->GetWindowConfigurer()->GetWindow());
  PerspectivesTabBar->setObjectName("PerspectivesTabBar");
  PerspectivesTabBar->addTab("Image Viewer");
  PerspectivesTabBar->addTab("DICOM-Manager");
  PerspectivesTabBar->setVisible(true);
  PerspectivesTabBar->setDrawBase(false);

  QPushButton* StyleUpdateButton = new QPushButton("Update Style", mainWindow);
  StyleUpdateButton->setMaximumWidth(100);
  StyleUpdateButton->setObjectName("StyleUpdateButton");
  QObject::connect(StyleUpdateButton, SIGNAL( clicked() ), this, SLOT( UpdateStyle() ));

  QToolButton* OpenFileButton = new QToolButton(mainWindow);
  OpenFileButton->setMaximumWidth(100);
  OpenFileButton->setObjectName("FileOpenButton");
  OpenFileButton->setText("Open File");
  QObject::connect(OpenFileButton, SIGNAL( clicked() ), this, SLOT( OpenFile() ));

  QWidget* PageComposite = new QWidget(CentralWidget);
  PageComposite->setObjectName("PageComposite");
  PageComposite->setVisible(true);

  //the layouts
  QVBoxLayout* CentralWidgetLayout = new QVBoxLayout(CentralWidget);
  CentralWidgetLayout->contentsMargins();
  CentralWidgetLayout->setContentsMargins(9,9,9,9);
  CentralWidgetLayout->setSpacing(0);
  CentralWidgetLayout->setObjectName("CentralWidgetLayout");

  QHBoxLayout* PerspectivesLayer = new QHBoxLayout(mainWindow);
  PerspectivesLayer->setObjectName("PerspectivesLayer");

  QHBoxLayout* PageCompositeLayout = new QHBoxLayout(PageComposite);
  PageCompositeLayout->setContentsMargins(0,0,0,0);
  PageCompositeLayout->setSpacing(0);
  PageComposite->setLayout(PageCompositeLayout);
// //! [WorkbenchWindowAdvisorCreateWindowContents]
  //all glued together
  mainWindow->setCentralWidget(CentralWidget);
  CentralWidgetLayout->addLayout(PerspectivesLayer);
  CentralWidgetLayout->addWidget(PageComposite);
  CentralWidget->setLayout(CentralWidgetLayout);
  PerspectivesLayer->addWidget(PerspectivesTabBar);
  PerspectivesLayer->addSpacing(300);
  PerspectivesLayer->addWidget(OpenFileButton);

  //for style customization convenience
  /*PerspectivesLayer->addSpacing(10);
  PerspectivesLayer->addWidget(StyleUpdateButton);*/

  //for correct initial layout, see also bug#1654
  CentralWidgetLayout->activate();
  CentralWidgetLayout->update();

  this->GetWindowConfigurer()->CreatePageComposite(PageComposite);
// //! [WorkbenchWindowAdvisorCreateWindowContents]
}