Example #1
0
void MainWindow::changeScreen(QWidget* screen){
	mCurrentScreen = screen;

	QLayout* layout = ui.screenContainer->layout();
	layout->removeWidget(layout->itemAt(0)->widget());
	layout->addWidget(mCurrentScreen);
}
Example #2
0
void QToolBar::setIconSize(const QSize &iconSize)
{
    Q_D(QToolBar);
    QSize sz = iconSize;
    if (!sz.isValid()) {
        QMainWindow *mw = qobject_cast<QMainWindow *>(parentWidget());
        if (mw && mw->layout()) {
            QLayout *layout = mw->layout();
            int i = 0;
            QLayoutItem *item = 0;
            do {
                item = layout->itemAt(i++);
                if (item && (item->widget() == this))
                    sz = mw->iconSize();
            } while (!sz.isValid() && item != 0);
        }
    }
    if (!sz.isValid()) {
        const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this);
        sz = QSize(metric, metric);
    }
    if (d->iconSize != sz) {
        d->iconSize = sz;
        setMinimumSize(0, 0);
        emit iconSizeChanged(d->iconSize);
    }
    d->explicitIconSize = iconSize.isValid();

    d->layout->invalidate();
}
bool MTPageNym_AltLocation::deleteSingleContactItem(GroupBoxContactItems * pGroupBox, QWidget * pWidget)
{
    if (nullptr == pGroupBox || nullptr == pWidget)
        return false;

    // We have to remove the radio button from the buttongroup.
    QLayout * pItemLayout = pWidget->layout(); // Combo, Line Edit, Radio, Delete

    if (nullptr != pItemLayout)
    {
        const int nIndexRadioBtn  = 2; // todo hardcoding.
        QWidget * pRadioBtnWidget = pItemLayout->itemAt(nIndexRadioBtn)->widget();

        if (nullptr != pRadioBtnWidget)
        {
            QRadioButton * pRadioBtn = dynamic_cast<QRadioButton *>(pRadioBtnWidget);
            if (nullptr != pRadioBtn)
            {
                pGroupBox->removeRadioButton(pRadioBtn);
            }
        }
    }
    // --------------------------------------
    pGroupBox->layout()->removeWidget(pWidget);

    pWidget->setParent(nullptr);
    pWidget->disconnect();
    pWidget->deleteLater();

    PrepareOutputData();

    return true;
}
Example #4
0
//---------------------------------------------------------------------------
PlotLegend::PlotLegend( QWidget *parent ):
        QwtLegend( parent )
{
    setMinimumHeight( 1 );
    setMaxColumns( 1 );
    setContentsMargins( 0, 0, 0, 0 );

    QLayout* layout = contentsWidget()->layout();
    layout->setAlignment( Qt::AlignLeft | Qt::AlignTop );
    layout->setSpacing( 0 );

    QScrollArea *scrollArea = findChild<QScrollArea *>();
    if ( scrollArea )
    {
        scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
        scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    }

#if 1
    QFont fnt = font();
    if ( fnt.pointSize() > 8 )
    {
        fnt.setPointSize( 8 );
        setFont( fnt );
    }
#endif
}
/*!
  Print the legend into a given rectangle.

  \param plot Plot widget
  \param painter Painter
  \param rect Bounding rectangle
*/
void QwtPlotRenderer::renderLegend( const QwtPlot *plot,
    QPainter *painter, const QRectF &rect ) const
{
    if ( !plot->legend() || plot->legend()->isEmpty() )
        return;

    QLayout *l = plot->legend()->contentsWidget()->layout();
    if ( l == 0 || !l->inherits( "QwtDynGridLayout" ) )
        return;

    QwtDynGridLayout *legendLayout = ( QwtDynGridLayout * )l;

    uint numCols = legendLayout->columnsForWidth( rect.width() );
    QList<QRect> itemRects =
        legendLayout->layoutItems( rect.toRect(), numCols );

    int index = 0;

    for ( int i = 0; i < legendLayout->count(); i++ )
    {
        QLayoutItem *item = legendLayout->itemAt( i );
        QWidget *w = item->widget();
        if ( w )
        {
            painter->save();

            painter->setClipRect( itemRects[index] );
            renderLegendItem( plot, painter, w, itemRects[index] );

            index++;
            painter->restore();
        }
    }
}
Example #6
0
void CCanvasQuickView::update(CDiagram *d)
{
	QRectF				r;
	CDiagramEditor		*editor = NULL;
	CDiagramView		*view = NULL;
	QLayout				*layout = NULL;

	layout = ui->m_miniViewHolder->layout();
	if (layout && m_view)
	{
		layout->removeWidget(m_view);
		m_view->setParent(NULL);
		m_view = NULL;
	}

	m_d = d;
	if (m_d)
	{
		editor = dynamic_cast<CDiagramEditor*>(m_d->getMainView());
		if (editor)
		{
			view = editor->diagramView();
			if (view)
			{
				view->setParent(this);
				layout->addWidget(view);
				m_view = view;
			}
		}
	}
}
Example #7
0
// Display the model's list of material
void ModelProperties::displayListOfMaterial(bool show)
{
	if (show)
	{
		if (NULL == m_pListOfMaterial)
		{
			m_pListOfMaterial= new ListOfMaterial(m_pOpenglView, materialListGroup);
			QLayout *pLayout = materialListGroup->layout();
			if (NULL == pLayout)
			{
				pLayout= new QVBoxLayout;
				materialListGroup->setLayout(pLayout);
			}
			pLayout->addWidget(m_pListOfMaterial);
			m_pListOfMaterial->showOnlyItemList(true);
			QList<GLC_Material*> materialList= m_FileEntry.getWorld().listOfMaterials();
			m_pListOfMaterial->CreateOrUpdate(materialList);
		}
		m_pListOfMaterial->show();
	}
	else
	{

		m_pListOfMaterial->hide();
	}
}
Example #8
0
Group *Widget::createGroup(int groupId)
{
    Group* g = GroupList::findGroup(groupId);
    if (g)
    {
        qWarning() << "Widget::createGroup: Group already exists";
        return g;
    }

    QString groupName = QString("Groupchat #%1").arg(groupId);
    Group* newgroup = GroupList::addGroup(groupId, groupName, true);
    QLayout* layout = contactListWidget->getGroupLayout();
    layout->addWidget(newgroup->getGroupWidget());
    newgroup->getGroupWidget()->updateStatusLight();

    Core* core = Nexus::getCore();
    connect(settingsWidget, &SettingsWidget::compactToggled, newgroup->getGroupWidget(), &GenericChatroomWidget::onCompactChanged);
    connect(newgroup->getGroupWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*)));
    connect(newgroup->getGroupWidget(), SIGNAL(removeGroup(int)), this, SLOT(removeGroup(int)));
    connect(newgroup->getGroupWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), newgroup->getChatForm(), SLOT(focusInput()));
    connect(newgroup->getChatForm(), SIGNAL(sendMessage(int,QString)), core, SLOT(sendGroupMessage(int,QString)));
    connect(newgroup->getChatForm(), SIGNAL(sendAction(int,QString)), core, SLOT(sendGroupAction(int,QString)));
    connect(newgroup->getChatForm(), &GroupChatForm::groupTitleChanged, core, &Core::changeGroupTitle);
    return newgroup;
}
Example #9
0
QWidget *ShapeFileImporter::getImportOptionsWidget(DataDescriptor *pDescriptor)
{
   createFeatureClassIfNeeded(pDescriptor);
   if (mpFeatureClass.get() == NULL)
   {
      return NULL;
   }

   if (mpOptionsWidget == NULL)
   {
      mpOptionsWidget = new FeatureClassWidget;
   }

   VERIFYRV(mpOptionsWidget != NULL, NULL);

   mpOptionsWidget->initialize(mpFeatureClass.get());
   mpOptionsWidget->setAvailableConnectionTypes(getAvailableConnectionTypes());

   QLayout* pLayout = mpOptionsWidget->layout();
   if (pLayout != NULL)
   {
      pLayout->setMargin(10);
   }

   return mpOptionsWidget;
}
Example #10
0
/*!
    \internal
*/
QLayout *QFormBuilder::createLayout(const QString &layoutName, QObject *parent, const QString &name)
{
    QLayout *l = 0;

    QWidget *parentWidget = qobject_cast<QWidget*>(parent);
    QLayout *parentLayout = qobject_cast<QLayout*>(parent);

    Q_ASSERT(parentWidget || parentLayout);

#define DECLARE_WIDGET(W, C)
#define DECLARE_COMPAT_WIDGET(W, C)

#define DECLARE_LAYOUT(L, C) \
    if (layoutName == QLatin1String(#L)) { \
        Q_ASSERT(l == 0); \
        l = parentLayout \
            ? new L() \
            : new L(parentWidget); \
    }

#include "widgets.table"

#undef DECLARE_LAYOUT
#undef DECLARE_COMPAT_WIDGET
#undef DECLARE_WIDGET

    if (l) {
        l->setObjectName(name);
    } else {
        qWarning() << QCoreApplication::translate("QFormBuilder", "The layout type `%1' is not supported.").arg(layoutName);
    }

    return l;
}
Example #11
0
void Widget::addFriend(int friendId, const QString &userId)
{
    qDebug() << "Adding friend with id "+userId;
    Friend* newfriend = FriendList::addFriend(friendId, userId);
    QLayout* layout = contactListWidget->getFriendLayout(Status::Offline);
    layout->addWidget(newfriend->widget);
    connect(newfriend->widget, SIGNAL(friendWidgetClicked(FriendWidget*)), this, SLOT(onFriendWidgetClicked(FriendWidget*)));
    connect(newfriend->widget, SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int)));
    connect(newfriend->widget, SIGNAL(copyFriendIdToClipboard(int)), this, SLOT(copyFriendIdToClipboard(int)));
    connect(newfriend->chatForm, SIGNAL(sendMessage(int,QString)), core, SLOT(sendMessage(int,QString)));
    connect(newfriend->chatForm, SIGNAL(sendFile(int32_t, QString, QString, long long)), core, SLOT(sendFile(int32_t, QString, QString, long long)));
    connect(newfriend->chatForm, SIGNAL(answerCall(int)), core, SLOT(answerCall(int)));
    connect(newfriend->chatForm, SIGNAL(hangupCall(int)), core, SLOT(hangupCall(int)));
    connect(newfriend->chatForm, SIGNAL(startCall(int)), core, SLOT(startCall(int)));
    connect(newfriend->chatForm, SIGNAL(startVideoCall(int,bool)), core, SLOT(startCall(int,bool)));
    connect(newfriend->chatForm, SIGNAL(cancelCall(int,int)), core, SLOT(cancelCall(int,int)));
    connect(newfriend->chatForm, SIGNAL(micMuteToggle(int)), core, SLOT(micMuteToggle(int)));
    connect(core, &Core::fileReceiveRequested, newfriend->chatForm, &ChatForm::onFileRecvRequest);
    connect(core, &Core::avInvite, newfriend->chatForm, &ChatForm::onAvInvite);
    connect(core, &Core::avStart, newfriend->chatForm, &ChatForm::onAvStart);
    connect(core, &Core::avCancel, newfriend->chatForm, &ChatForm::onAvCancel);
    connect(core, &Core::avEnd, newfriend->chatForm, &ChatForm::onAvEnd);
    connect(core, &Core::avRinging, newfriend->chatForm, &ChatForm::onAvRinging);
    connect(core, &Core::avStarting, newfriend->chatForm, &ChatForm::onAvStarting);
    connect(core, &Core::avEnding, newfriend->chatForm, &ChatForm::onAvEnding);
    connect(core, &Core::avRequestTimeout, newfriend->chatForm, &ChatForm::onAvRequestTimeout);
    connect(core, &Core::avPeerTimeout, newfriend->chatForm, &ChatForm::onAvPeerTimeout);
    connect(core, &Core::avMediaChange, newfriend->chatForm, &ChatForm::onAvMediaChange);
}
Example #12
0
void WidgetInspector::widgetSelected(const QModelIndex &index)
{
  if (index.isValid()) {
    QObject *obj = index.data(ObjectModel::ObjectRole).value<QObject*>();
    QWidget *widget = qobject_cast<QWidget*>(obj);
    QLayout* layout = qobject_cast<QLayout*>(obj);
    if (!widget && layout) {
      widget = layout->parentWidget();
    }

    ui->widgetPropertyWidget->setObject(obj);
    ui->widgetPreviewWidget->setWidget(widget);
    setActionsEnabled(widget != 0);

    if (widget && qobject_cast<QDesktopWidget*>(widget) == 0) {
      m_overlayWidget->placeOn(widget);
    } else {
      m_overlayWidget->placeOn(0);
    }
  } else {
    ui->widgetPropertyWidget->setObject(0);
    ui->widgetPreviewWidget->setWidget(0);
    m_overlayWidget->placeOn(0);
    setActionsEnabled(false);
  }
}
Example #13
0
RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f)
    : QWidget(parent, f)
    , mRootNode(0)
{

    osgViewer::CompositeViewer& viewer = CompositeViewer::get();

    osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
    //ds->setNumMultiSamples(8);

    osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
    traits->windowName = "";
    traits->windowDecoration = true;
    traits->x = 0;
    traits->y = 0;
    traits->width = width();
    traits->height = height();
    traits->doubleBuffer = true;
    traits->alpha = ds->getMinimumNumAlphaBits();
    traits->stencil = ds->getMinimumNumStencilBits();
    traits->sampleBuffers = ds->getMultiSamples();
    traits->samples = ds->getNumMultiSamples();
    // Doesn't make much sense as we're running on demand updates, and there seems to be a bug with the refresh rate when running multiple QGLWidgets
    traits->vsync = false;

    mView = new osgViewer::View;

    osg::ref_ptr<osgQt::GraphicsWindowQt> window = new osgQt::GraphicsWindowQt(traits.get());
    QLayout* layout = new QHBoxLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->addWidget(window->getGLWidget());
    setLayout(layout);

    // Pass events through this widget first
    window->getGLWidget()->installEventFilter(this);

    mView->getCamera()->setGraphicsContext(window);
    mView->getCamera()->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
    mView->getCamera()->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) );
    mView->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f, 10000.0f );

    SceneUtil::LightManager* lightMgr = new SceneUtil::LightManager;
    lightMgr->setStartLight(1);
    lightMgr->setLightingMask(Mask_Lighting);
    mRootNode = lightMgr;

    mView->getCamera()->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
    mView->getCamera()->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::ON);

    mView->setSceneData(mRootNode);

    // Press S to reveal profiling stats
    mView->addEventHandler(new osgViewer::StatsHandler);

    mView->getCamera()->setCullMask(~(Mask_UpdateVisitor));

    viewer.addView(mView);
    viewer.setDone(false);
    viewer.realize();
}
    CrmaccountMergeResultPagePrivate(QWizardPage *parent)
      : _parent(parent)
    {
      _crmaccount = new crmaccount();
      _crmaccount->_save->setVisible(false);
      _crmaccount->_close->setVisible(false);

      QString errmsg;
      bool    ok = false;
      _obsoletemqlstr = MQLUtil::mqlLoad("crmaccountmerge", "wip", errmsg, &ok);
      if (!ok)
        ErrorReporter::error(QtCriticalMsg, _parent,
                             QT_TRANSLATE_NOOP("CrmaccountMergeResultPage",
                                               "Getting Source CRM Accounts"),
                             errmsg, __FILE__, __LINE__);

      ParameterList params;
      params.append("mode", "view");
      _crmaccount->set(params);

      QWidget *sa = _parent->findChild<QWidget*>("_resultScrollAreaContents");
      QLayout *lyt = sa ? sa->layout() : 0;
      if (lyt)
        lyt->addWidget(_crmaccount);
      else
        ErrorReporter::error(QtWarningMsg, _parent,
                             QT_TRANSLATE_NOOP("CrmaccountMergeResultPage",
                                               "Could not draw CRM Account"),
                             QT_TRANSLATE_NOOP("CrmaccountMergeResultPage",
                                "Could not find the portion of the window "
                                "in which to draw the target CRM Account."));
    };
ItemSelectorWidget::ItemSelectorWidget( QWidget* parent )
    :StylableWidget(parent), m_clearText( false )
{
    QLayout* layout = new FlowLayout( this, 0, 0, 0 );
    layout->setContentsMargins( 0, 0, 0, 0 );
    layout->setSpacing( 0 );
}
Example #16
0
SymbolDialog::SymbolDialog(QWidget* parent)
   : QWidget(parent, Qt::WindowFlags(Qt::Dialog | Qt::Window))
      {
      setupUi(this);
      int idx = 0;
      int currentIndex = 0;
      for (const ScoreFont& f : ScoreFont::scoreFonts()) {
            fontList->addItem(f.name());
            if (f.name() == "Bravura")
                  currentIndex = idx;
            ++idx;
            }
      fontList->setCurrentIndex(currentIndex);

      setWindowTitle(tr("MuseScore: Symbols"));
      QLayout* l = new QVBoxLayout();
      frame->setLayout(l);
      createSymbolPalette();

      QScrollArea* sa = new PaletteScrollArea(sp);
      l->addWidget(sa);

      sp->setAcceptDrops(false);
      sp->setDrawGrid(true);
      sp->setSelectable(true);

      connect(systemFlag, SIGNAL(stateChanged(int)), SLOT(systemFlagChanged(int)));
      connect(fontList, SIGNAL(currentIndexChanged(int)), SLOT(systemFontChanged(int)));

      sa->setWidget(sp);
      }
void QwtPlot::printLegend(QPainter *painter, const QRect &rect) const
{
    if ( !d_legend || d_legend->isEmpty() )
        return;

    QLayout *l = d_legend->contentsWidget()->layout();
    if ( l == 0 || !l->inherits("QwtDynGridLayout") )
        return;

    QwtDynGridLayout *legendLayout = (QwtDynGridLayout *)l;

    uint numCols = legendLayout->columnsForWidth(rect.width());
    QValueList<QRect> itemRects = 
        legendLayout->layoutItems(rect, numCols);

    int index = 0;

    QLayoutIterator layoutIterator = legendLayout->iterator();
    for ( QLayoutItem *item = layoutIterator.current(); 
        item != 0; item = ++layoutIterator)
    {
        QWidget *w = item->widget();
        if ( w )
        {
            painter->save();
            painter->setClipping(TRUE);
            QwtPainter::setClipRect(painter, itemRects[index]);

            printLegendItem(painter, w, itemRects[index]);

            index++;
            painter->restore();
        }
    }
}
Example #18
0
bool LiteFindPlugin::load(LiteApi::IApplication *app)
{
    m_liteApp = app;

    QLayout *layout = m_liteApp->editorManager()->widget()->layout();
    if (!layout) {
        return false;
    }

    QMenu *menu = m_liteApp->actionManager()->loadMenu(ID_MENU_FIND);
    if (!menu) {
        return false;
    }

    m_findEditor = new FindEditor(m_liteApp,this);
    m_findEditor->widget()->hide();

    layout->addWidget(m_findEditor->widget());

    LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Find");

    m_findAct = new QAction(tr("Find"),this);
    actionContext->regAction(m_findAct,"Find",QKeySequence::Find);

    m_findNextAct = new QAction(tr("Find Next"),this);
    actionContext->regAction(m_findNextAct,"FindNext",QKeySequence::FindNext);

    m_findPrevAct = new QAction(tr("Find Previous"),this);
    actionContext->regAction(m_findPrevAct,"FindPrevious",QKeySequence::FindPrevious);

    m_replaceAct = new QAction(tr("Replace"),this);
#ifdef Q_OS_MAC
    actionContext->regAction(m_replaceAct,"Replace","ALT+CTRL+F");
#else
    actionContext->regAction(m_replaceAct,"Replace",QKeySequence::Replace);
#endif
    m_fileSearchAct = new QAction(tr("File Search"),this);
    actionContext->regAction(m_fileSearchAct,"FileSearch","Ctrl+Shift+F");

    menu->addAction(m_findAct);
    menu->addAction(m_findNextAct);
    menu->addAction(m_findPrevAct);
    menu->addSeparator();
    menu->addAction(m_replaceAct);
    menu->addSeparator();
    menu->addAction(m_fileSearchAct);

    connect(m_findAct,SIGNAL(triggered()),this,SLOT(find()));
    connect(m_findNextAct,SIGNAL(triggered()),m_findEditor,SLOT(findNext()));
    connect(m_findPrevAct,SIGNAL(triggered()),m_findEditor,SLOT(findPrev()));
    connect(m_replaceAct,SIGNAL(triggered()),this,SLOT(replace()));

    connect(m_liteApp,SIGNAL(key_escape()),this,SLOT(hideFind()));

    FileSearchManager *manager = new FileSearchManager(m_liteApp,this);
    FileSearch *fileSearch = new FileSearch(m_liteApp,manager);
    manager->addFileSearch(fileSearch);
    connect(m_fileSearchAct,SIGNAL(triggered()),manager,SLOT(newSearch()));
    return true;
}
Example #19
0
/*!
    \internal
*/
QLayout *QFormBuilder::create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget)
{
    // Is this a temporary layout widget used to represent QLayout hierarchies in Designer?
    // Set its margins to 0.
    bool layoutWidget = QFormBuilderExtra::instance(this)->processingLayoutWidget();
    QLayout *l = QAbstractFormBuilder::create(ui_layout, layout, parentWidget);
    if (layoutWidget) {
        const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
        int left, top, right, bottom;
        left = top = right = bottom = 0;
        const DomPropertyHash properties = propertyMap(ui_layout->elementProperty());

        if (DomProperty *prop = properties.value(strings.leftMarginProperty))
            left = prop->elementNumber();

        if (DomProperty *prop = properties.value(strings.topMarginProperty))
            top = prop->elementNumber();

        if (DomProperty *prop = properties.value(strings.rightMarginProperty))
            right = prop->elementNumber();

        if (DomProperty *prop = properties.value(strings.bottomMarginProperty))
            bottom = prop->elementNumber();

        l->setContentsMargins(left, top, right, bottom);
        QFormBuilderExtra::instance(this)->setProcessingLayoutWidget(false);
    }
    return l;
}
Example #20
0
void KviStatusBar::recalcMinimumHeight()
{
	int iSize = 18;
	int iHeight = m_pMessageLabel->sizeHint().height();
	if(iHeight > iSize)
		iSize = iHeight;

	for(KviStatusBarApplet * pApplet = m_pAppletList->last(); pApplet; pApplet = m_pAppletList->prev())
	{
		iHeight = pApplet->sizeHint().height();
		if(iHeight > iSize)
			iSize = iHeight;
	}

	iSize += (VMARGIN * 2) + RICHTEXTLABELTRICK;
	if(m_iLastMinimumHeight != iSize)
	{
		m_iLastMinimumHeight = iSize;
		setMinimumHeight(iSize);
		QLayout * l = layout();
		if(l)
		{
			if(l->inherits("QBoxLayout"))
				((QBoxLayout *)l)->addStrut(iSize);
		}
	}
}
Example #21
0
// Writes the user input from the form into the oc_auth_form structs we got from
// libopenconnect, and wakes the worker thread up to try to log in and obtain a
// cookie with this data
void OpenconnectAuthWidget::formLoginClicked()
{
    Q_D(OpenconnectAuthWidget);

    const int lastIndex = d->ui.loginBoxLayout->count() - 1;
    QLayout *layout = d->ui.loginBoxLayout->itemAt(d->passwordFormIndex)->layout();
    struct oc_auth_form *form = (struct oc_auth_form *) d->ui.loginBoxLayout->itemAt(lastIndex)->widget()->property("openconnect_form").value<quintptr>();

    for (int i = 0; i < layout->count(); i++) {
        QLayoutItem *item = layout->itemAt(i);
        QWidget *widget = item->widget();
        if (widget && widget->property("openconnect_opt").isValid()) {
            struct oc_form_opt *opt = (struct oc_form_opt *) widget->property("openconnect_opt").value<quintptr>();
            const QString key = QString("form:%1:%2").arg(QLatin1String(form->auth_id)).arg(QLatin1String(opt->name));
            if (opt->type == OC_FORM_OPT_PASSWORD || opt->type == OC_FORM_OPT_TEXT) {
                QLineEdit *le = qobject_cast<QLineEdit*>(widget);
                QByteArray text = le->text().toUtf8();
                openconnect_set_option_value(opt, text.data());
                if (opt->type == OC_FORM_OPT_TEXT) {
                    d->secrets.insert(key, le->text());
                } else {
                    d->tmpSecrets.insert(key, le->text());
                }
            } else if (opt->type == OC_FORM_OPT_SELECT) {
                QComboBox *cbo = qobject_cast<QComboBox*>(widget);
                QByteArray text = cbo->itemData(cbo->currentIndex()).toString().toAscii();
                openconnect_set_option_value(opt, text.data());
                d->secrets.insert(key,cbo->itemData(cbo->currentIndex()).toString());
            }
        }
    }

    deleteAllFromLayout(d->ui.loginBoxLayout);
    d->workerWaiting.wakeAll();
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_layout_at (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QLayout *layout = self->v8_to_qobject<QLayout> (Args.This ());
      if (layout) {

         if (Args.Length () > 0) {

            QWidget *widget = layout->itemAt (v8_to_int32 (Args[0]))->widget ();
            if (widget) {

               result = self->create_v8_qwidget (widget);
            }
         }
      }
   }

   return scope.Close (result);
}
Example #23
0
void StartLiveDataDialog::initListenerPropLayout(const QString& inst)
{
  // remove previous listener's properties
  auto props = m_algorithm->getPropertiesInGroup("ListenerProperties");
  for(auto prop = props.begin(); prop != props.end(); ++prop)
  {
    QString propName = QString::fromStdString((**prop).name());
    if ( m_algProperties.contains( propName ) )
    {
      m_algProperties.remove( propName );
    }
  }

  // update algorithm's properties
  m_algorithm->setPropertyValue("Instrument", inst.toStdString());
  // create or clear the layout
  QLayout *layout = ui.listenerProps->layout();
  if ( !layout )
  {
    QGridLayout *listenerPropLayout = new QGridLayout(ui.listenerProps);
    layout = listenerPropLayout;
  }
  else
  {
    QLayoutItem *child;
    while ((child = layout->takeAt(0)) != NULL)  
    {
      child->widget()->close();
      delete child;
    }
  }

  // find the listener's properties
  props = m_algorithm->getPropertiesInGroup("ListenerProperties");

  // no properties - don't show the box
  if ( props.empty() )
  {
    ui.listenerProps->setVisible(false);
    return;
  }
  
  auto gridLayout = static_cast<QGridLayout*>( layout );
  // add widgets for the listener's properties
  for(auto prop = props.begin(); prop != props.end(); ++prop)
  {
    int row = static_cast<int>(std::distance( props.begin(), prop ));
    QString propName = QString::fromStdString((**prop).name());
    gridLayout->addWidget( new QLabel(propName), row, 0 );
    QLineEdit *propWidget = new QLineEdit();
    gridLayout->addWidget( propWidget, row, 1 );
    if ( !m_algProperties.contains( propName ) )
    {
      m_algProperties.append( propName );
    }
    tie(propWidget, propName, gridLayout);
  }
  ui.listenerProps->setVisible(true);

}
void MainWindow::swapDZtoLayerTab(){
    qDebug() << "swap";
    QLayout *mainLayout = this->centralWidget()->layout();
    mainLayout->replaceWidget(dropZone_m, tabWidget_m);
    tabWidget_m->show();
    dropZone_m->hide();
}
Example #25
0
ToolBarImp::ToolBarImp(const string& id, const string& name, QWidget* parent) :
   QToolBar(QString::fromStdString(name), parent),
   WindowImp(id, name),
   mpMenuBar(new MenuBarImp(QString::fromStdString(name), this))
{
   mpShowAction = new QAction("&Show", this);
   mpShowAction->setAutoRepeat(false);
   mpShowAction->setStatusTip("Shows the window");

   mpHideAction = new QAction("&Hide", this);
   mpHideAction->setAutoRepeat(false);
   mpHideAction->setStatusTip("Hides the window");

   // Initialization
   setIconSize(QSize(16, 16));
   addWidget(mpMenuBar);
   setContextMenuPolicy(Qt::DefaultContextMenu);

   VERIFYNR(connect(mpShowAction, SIGNAL(triggered()), this, SLOT(show())));
   VERIFYNR(connect(mpHideAction, SIGNAL(triggered()), this, SLOT(hide())));

   // Prevent the menu bar from stretching
   QLayout* pLayout = layout();
   if (pLayout != NULL)
   {
      pLayout->setAlignment(mpMenuBar, Qt::AlignLeft | Qt::AlignVCenter);
   }
}
/** Initializes the startup section of the OD. */
CDisplaySettingsPage::CDisplaySettingsPage(QWidget *parent)
        : BtConfigPage(parent)
{
    QVBoxLayout* layout = new QVBoxLayout(this);

    { //startup logo
        m_showLogoCheck = new QCheckBox(this);
        m_showLogoCheck->setText(tr("Show startup logo"));
        m_showLogoCheck->setToolTip(tr("Show the BibleTime logo on startup"));

        m_showLogoCheck->setChecked(CBTConfig::get(CBTConfig::logo));
        layout->addWidget(m_showLogoCheck);
    }
    layout->addSpacing(20);

    layout->addWidget(
        util::tool::explanationLabel(
            this,
            tr("Display templates"),
            tr("Display templates define how text is displayed.")
        )
    );

    QHBoxLayout* hboxlayout = new QHBoxLayout();

    m_styleChooserCombo = new QComboBox( this ); //create first to enable buddy for label
    connect( m_styleChooserCombo, SIGNAL( activated( int ) ),
             this, SLOT( updateStylePreview() ) );

    QLabel* availableLabel = new QLabel(tr("Available display styles:"), this);
    availableLabel->setBuddy(m_styleChooserCombo);
    hboxlayout->addWidget(availableLabel);
    hboxlayout->addWidget( m_styleChooserCombo );
    hboxlayout->addStretch();
    layout->addLayout( hboxlayout );

    QWidget* webViewWidget = new CWebViewerWidget(this);
    QLayout* webViewLayout = new QVBoxLayout(webViewWidget);
    m_stylePreviewViewer = new QWebView(webViewWidget);
    QLabel* previewLabel = new QLabel(tr("Style preview"), webViewWidget);
    previewLabel->setBuddy(m_stylePreviewViewer);
    webViewLayout->addWidget(previewLabel);
    webViewLayout->addWidget(m_stylePreviewViewer);
    webViewWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
    layout->addWidget(webViewWidget);

    m_styleChooserCombo->addItems(
        CPointers::displayTemplateManager()->availableTemplates()
    );

    for (int i = 0; i < m_styleChooserCombo->count(); ++i) {
        if ( m_styleChooserCombo->itemText(i) == CBTConfig::get(CBTConfig::displayStyle) ) {
            m_styleChooserCombo->setCurrentIndex( i );
            break;
        }
    }

    updateStylePreview(); //render it
}
Example #27
0
QtResourceView::QtResourceView(QDesignerFormEditorInterface *core, QWidget *parent) :
    QWidget(parent),
    d_ptr(new QtResourceViewPrivate(core))
{
    d_ptr->q_ptr = this;

    QIcon editIcon = QIcon::fromTheme("document-properties", qdesigner_internal::createIconSet(QLatin1String("edit.png")));
    d_ptr->m_editResourcesAction = new QAction(editIcon, tr("Edit Resources..."), this);
    d_ptr->m_toolBar->addAction(d_ptr->m_editResourcesAction);
    connect(d_ptr->m_editResourcesAction, SIGNAL(triggered()), this, SLOT(slotEditResources()));
    d_ptr->m_editResourcesAction->setEnabled(false);

    QIcon refreshIcon = QIcon::fromTheme("view-refresh", qdesigner_internal::createIconSet(QLatin1String("reload.png")));
    d_ptr->m_reloadResourcesAction = new QAction(refreshIcon, tr("Reload"), this);

    d_ptr->m_toolBar->addAction(d_ptr->m_reloadResourcesAction);
    connect(d_ptr->m_reloadResourcesAction, SIGNAL(triggered()), this, SLOT(slotReloadResources()));
    d_ptr->m_reloadResourcesAction->setEnabled(false);

    QIcon copyIcon = QIcon::fromTheme("edit-copy", qdesigner_internal::createIconSet(QLatin1String("editcopy.png")));
    d_ptr->m_copyResourcePathAction = new QAction(copyIcon, tr("Copy Path"), this);
    connect(d_ptr->m_copyResourcePathAction, SIGNAL(triggered()), this, SLOT(slotCopyResourcePath()));
    d_ptr->m_copyResourcePathAction->setEnabled(false);

    //d_ptr->m_filterWidget = new qdesigner_internal::FilterWidget(0, qdesigner_internal::FilterWidget::LayoutAlignNone);
    d_ptr->m_filterWidget = new qdesigner_internal::FilterWidget(d_ptr->m_toolBar);
    d_ptr->m_toolBar->addWidget(d_ptr->m_filterWidget);
    connect(d_ptr->m_filterWidget, SIGNAL(filterChanged(QString)), this, SLOT(slotFilterChanged(QString)));

    d_ptr->m_splitter = new QSplitter;
    d_ptr->m_splitter->setChildrenCollapsible(false);
    d_ptr->m_splitter->addWidget(d_ptr->m_treeWidget);
    d_ptr->m_splitter->addWidget(d_ptr->m_listWidget);

    QLayout *layout = new QVBoxLayout(this);
    layout->setMargin(0);
    layout->setSpacing(0);
    layout->addWidget(d_ptr->m_toolBar);
    layout->addWidget(d_ptr->m_splitter);

    d_ptr->m_treeWidget->setColumnCount(1);
    d_ptr->m_treeWidget->header()->hide();
    d_ptr->m_treeWidget->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));

    d_ptr->m_listWidget->setViewMode(QListView::IconMode);
    d_ptr->m_listWidget->setResizeMode(QListView::Adjust);
    d_ptr->m_listWidget->setIconSize(QSize(48, 48));
    d_ptr->m_listWidget->setGridSize(QSize(64, 64));

    connect(d_ptr->m_treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
                    this, SLOT(slotCurrentPathChanged(QTreeWidgetItem*)));
    connect(d_ptr->m_listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
                    this, SLOT(slotCurrentResourceChanged(QListWidgetItem*)));
    connect(d_ptr->m_listWidget, SIGNAL(itemActivated(QListWidgetItem*)),
                    this, SLOT(slotResourceActivated(QListWidgetItem*)));
    d_ptr->m_listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(d_ptr->m_listWidget, SIGNAL(customContextMenuRequested(QPoint)),
                this, SLOT(slotListWidgetContextMenuRequested(QPoint)));
}
Example #28
0
valveDialog::valveDialog(unit *theValve, bool first, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::valveDialog)
{
    ui->setupUi(this);

    setWindowTitle("Define the valve");

    myUnit = theValve;
    if(myUnit->idunit == 62)//throttle
        ui->thermoBox->hide();
    else if(myUnit->idunit == 63)//thermo
        ui->throttleBox->hide();


    if(myUnit->idunit==63)
    {
        if(spnumber>3)
        {
            for(int i =0;i<spnumber;i++)
            {
                if(i!=myUnit->myNodes[0]->ndum-1&&i!=myUnit->myNodes[1]->ndum-1&&i!=myUnit->myNodes[2]->ndum-1)
                    ui->sensorBox->insertItem(0,QString::number(i+1));
            }
        }
        else
            ui->sensorBox->insertItem(0,"N/A");
    }


    if(!first)
    {
        ui->coefLine->setText(QString::number(myUnit->ht,'g',4));
        ui->lawLine->setText(QString::number(myUnit->devl,'g',4));
        if(myUnit->idunit==63)
        {
            ui->temperatureLine->setText(QString::number(myUnit->devg,'g',4));
            ui->temperatureUnitLine->setText(globalpara.unitname_temperature);
            int foundIndex = 0;
            for(int i = 0; i < ui->sensorBox->count();i++)
            {
                if(int(myUnit->devl)==ui->sensorBox->itemText(i).toInt())
                    foundIndex = i;
            }
            ui->sensorBox->setCurrentIndex(foundIndex);
        }
    }

    QLayout *mainLayout = layout();
    mainLayout->setSizeConstraint(QLayout::SetFixedSize);


    QRegExp regExp("[-.0-9]+$");
    QRegExpValidator *regExpValidator = new QRegExpValidator(regExp,this);

    ui->coefLine->setValidator(regExpValidator);
    ui->lawLine->setValidator(regExpValidator);
    ui->temperatureLine->setValidator(regExpValidator);
}
Example #29
0
void WWidgetGroup::setLayoutAlignment(int alignment) {
    //qDebug() << "WWidgetGroup::setLayoutAlignment" << alignment;

    QLayout* pLayout = layout();
    if (pLayout) {
        pLayout->setAlignment(static_cast<Qt::Alignment>(alignment));
    }
}
Example #30
0
void NLayoutPrototype::setSpacingAt(int index, int spacing)
{
	QLayout *layout = qscriptvalue_cast<QLayout *>(thisObject());
	if (layout) {
		layout->removeItem(layout->itemAt(index));
		dynamic_cast<QBoxLayout *>(layout)->insertSpacing(index, spacing);
	}
}