Ejemplo n.º 1
0
 void fixTabOrder() {
     QWidget *cur = NULL;
     if (hLayout->count() > 0)
         p->setTabOrder(p, (cur = hLayout->itemAt(0)->widget()));
     for (int i = 1; i < hLayout->count(); ++i) {
         QWidget *next = hLayout->itemAt(i)->widget();
         p->setTabOrder(cur, next);
         cur = next;
     }
 }
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);
}
Ejemplo n.º 3
0
IpWidget::IpWidget(QWidget *parent) : QFrame(parent)
{
    setFrameShape( QFrame::StyledPanel );
    setFrameShadow( QFrame::Sunken );

    QHBoxLayout* pLayout = new QHBoxLayout( this );
    setLayout( pLayout );
    pLayout->setContentsMargins( 0, 0, 0, 0 );
    pLayout->setSpacing( 0 );

    for ( int i = 0; i != QTUTL_IP_SIZE; ++i )
    {
        if ( i != 0 )
        {
            QLabel* pDot = new QLabel( ".", this );
            pDot->setStyleSheet( "background: white" );
            pLayout->addWidget( pDot );
            pLayout->setStretch( pLayout->count(), 0 );
        }

        lineEdits[i] = new QLineEdit( this );
        QLineEdit* pEdit = lineEdits[i];
        pEdit->installEventFilter( this );

        pLayout->addWidget( pEdit );
        pLayout->setStretch( pLayout->count(), 1 );

        pEdit->setFrame( false );
        pEdit->setAlignment( Qt::AlignCenter );

        QFont font = pEdit->font();
        font.setStyleHint( QFont::Monospace );
        font.setFixedPitch( true );
        pEdit->setFont( font );

        QRegExp rx ( "^(0|[1-9]|[1-9][0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))$" );
        QValidator *validator = new QRegExpValidator(rx, pEdit);
        pEdit->setValidator( validator );

    }

    lineEdits[0]->setText("127");
    lineEdits[1]->setText("0");
    lineEdits[2]->setText("0");
    lineEdits[3]->setText("1");

    setMaximumWidth( 30 * QTUTL_IP_SIZE );

    connect( this, SIGNAL(signalTextChanged(QLineEdit*)),
             this, SLOT(slotTextChanged(QLineEdit*)),
             Qt::QueuedConnection );
}
Ejemplo n.º 4
0
 void setReadOnly(bool isReadOnly) {
     m_isReadOnly = isReadOnly;
     for (int i = hLayout->count() - 1; i >= 0; --i) {
         QWidget *w = hLayout->itemAt(i)->widget();
         setWidgetReadOnly(w, isReadOnly);
     }
 }
Ejemplo n.º 5
0
void TestAnswersChooser::setState(ChooserState _state)
{
    if(_state == ChooseNums)
    {
        ui->numsChooser->setEnabled(true);

        ui->title->show();
        ui->subtitle->hide();

        m_demonstrator->hide();
    }
    else if(_state == ShowCorrect)
    {
        ui->numsChooser->setEnabled(false);

        ui->title->hide();
        ui->subtitle->show();

        QHBoxLayout* l = static_cast<QHBoxLayout*>(layout());
        if(l)
        {
            m_demonstrator->setCountdown(-1);
            l->insertWidget(l->count()-1, m_demonstrator);
            m_demonstrator->show();
        }
        else
            qDebug() << "Wrong layout type in " << Q_FUNC_INFO;
    }
    else if(_state == Finish)
        emit finished();
    else
        qDebug() << "smth goes wrong in" << Q_FUNC_INFO;
}
Ejemplo n.º 6
0
 void setStyleSheet(bool makeInnerWidgetsTransparent) {
     this->makeInnerWidgetsTransparent = makeInnerWidgetsTransparent;
     for (int i = hLayout->count() - 1; i >= 0; --i) {
         QWidget *w = hLayout->itemAt(i)->widget();
         if (w != NULL)
             w->setStyleSheet(makeInnerWidgetsTransparent ? transparentStyleSheet : normalStyleSheet);
     }
 }
Ejemplo n.º 7
0
ActionLineEditButton * ActionLineEdit::widgetForAction ( QAction * action )
{
	QHBoxLayout *lo = (QHBoxLayout *)layout();
	ActionLineEditButton *btn;
	for (int i=1, count=lo->count(); i<count; i++) {
		btn = (ActionLineEditButton *)lo->itemAt(i)->widget();
		if (btn->defaultAction() == action) {
			return btn;
		}
	}
	return 0;
}
Ejemplo n.º 8
0
void ActionLineEdit::actionEvent ( QActionEvent * event )
{
	QHBoxLayout *lo = (QHBoxLayout *)layout();
	QAction *act = event->action();
	ActionLineEditButton *btn;
	if (event->type() == QEvent::ActionAdded) {
		btn = new ActionLineEditButton(this);
		QAction *before = event->before();
		int beforeInd;
		if (before && (beforeInd = actions().indexOf(before)) >= 0) { //TODO test it
			lo->insertWidget(beforeInd + 1, btn); //1 - first item is spacer. skip it
		}
		else {
			lo->addWidget(btn);
		}
		btn->setDefaultAction(act);
	}
	else if (event->type() == QEvent::ActionRemoved) {
		for (int i=1, count=lo->count(); i<count; i++) {
			btn = (ActionLineEditButton *)lo->itemAt(i)->widget();
			if (btn->defaultAction() == act) {
				lo->removeWidget(btn);
				delete btn;
				break;
			}
		}
	}
	int sumWidth = 0;
	for (int i=1, count=lo->count(); i<count; i++) {
		btn = (ActionLineEditButton *)lo->itemAt(i)->widget();
		if (btn->defaultAction()->isVisible()) {
			sumWidth += btn->width();
		}
	}
	sumWidth += 4; //+4px padding between text and buttons. should looks better (magic number)
	int mLeft, mTop, mRight, mBottom;
	getTextMargins(&mLeft, &mTop, &mRight, &mBottom);
	setTextMargins(mLeft, mTop, sumWidth, mBottom);
}
Ejemplo n.º 9
0
    void verticallyStretchButtons() {
        /// do not vertically stretch if using transparent style sheet
        if (makeInnerWidgetsTransparent) return;

        /// check each widget inside MenuLineEdit
        for (int i = hLayout->count() - 1; i >= 0; --i) {
            QWidget *w = hLayout->itemAt(i)->widget();
            if (w != NULL && w != m_singleLineEditText && w != m_multiLineEditText) {
                /// for all widgets except the main editing widget: change tab focus policy
                QSizePolicy sp = w->sizePolicy();
                w->setSizePolicy(sp.horizontalPolicy(), QSizePolicy::MinimumExpanding);
            }
        }
    }
Ejemplo n.º 10
0
void QTitleWidget::addTitle(const QString &title)
{
    if(title == "" || m_textToTitle.keys().contains(title))
    {
        return;
    }

    QSingleTitleWidget * wid = new QSingleTitleWidget(title,this);
    wid->setVisible(true);
    QHBoxLayout *l = (QHBoxLayout*)layout();
    l->insertWidget(l->count()-4,wid);
    m_titles.append(wid);
    m_textToTitle.insert(title,wid);
    connect(wid,SIGNAL(remove()),this,SLOT(titleDeled()));
}
Ejemplo n.º 11
0
    virtual void notificationEvent(int eventId) {
        if (eventId == MenuLineEdit::MenuLineConfigurationChangedEvent) {
            /// load setting limitKeyboardTabStops
            KSharedConfigPtr config(KSharedConfig::openConfig(QStringLiteral("kbibtexrc")));
            static QString const configGroupName = QStringLiteral("User Interface");
            KConfigGroup configGroup(config, configGroupName);
            const bool limitKeyboardTabStops = configGroup.readEntry(MenuLineEdit::keyLimitKeyboardTabStops, false);

            /// check each widget inside MenuLineEdit
            for (int i = hLayout->count() - 1; i >= 0; --i) {
                QWidget *w = hLayout->itemAt(i)->widget();
                if (w != NULL && w != m_singleLineEditText && w != m_multiLineEditText) {
                    /// for all widgets except the main editing widget: change tab focus policy
                    w->setFocusPolicy(limitKeyboardTabStops ? Qt::ClickFocus : Qt::StrongFocus);
                }
            }
        }
    }
Ejemplo n.º 12
0
// +-----------------------------------------------------------
gc::LikertScale::LikertScale(const uint iAnswers, QWidget *pParent) : QWidget(pParent)
{
	QVBoxLayout *pLayout = new QVBoxLayout();
	setLayout(pLayout);

	QHBoxLayout *pOptionsLayout = new QHBoxLayout();
	pOptionsLayout->setAlignment(Qt::AlignLeft);
	pLayout->addLayout(pOptionsLayout);

	for(uint i = 0; i < iAnswers; i++)
		m_lButtons.append(new QRadioButton(this));

	foreach(QRadioButton *pButton, m_lButtons)
	{
		pButton->setCursor(Qt::PointingHandCursor);
		if(pOptionsLayout->count() > 0)
			pOptionsLayout->addSpacing(60);
		pOptionsLayout->addWidget(pButton);
		connect(pButton, &QRadioButton::toggled, this, &LikertScale::onButtonToggled);
	}
Ejemplo n.º 13
0
 ~MenuLineEditPrivate() {
     for (int i = hLayout->count() - 1; i >= 0; --i) {
         QWidget *w = hLayout->itemAt(i)->widget();
         w->deleteLater();
     }
 }
Ejemplo n.º 14
0
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());
}
Ejemplo n.º 15
0
 void setEnabledLayout(bool enabled) {
    for (int i = 0; i < groupLayout.count(); i++)
       if (auto widget = groupLayout.itemAt(i)->widget())
          widget->setEnabled(enabled);
 }
Ejemplo n.º 16
0
void CTimelineWidget::UpdateTimeline()
{
    QLayoutItem *child;
    if(layout() != Q_NULLPTR)
    {
        while (((child = layout()->takeAt(0)) != 0)) {
            //                                    delete child->widget();
            delete child;
        }
        delete layout();
    }   
    m_pLoader->start();
    QHBoxLayout* pHBLayout = new QHBoxLayout(this);
    pHBLayout->setSpacing(6);
    pHBLayout->setContentsMargins(3, 3, 3, 3);
    QPalette Pal(palette());
    Pal.setColor(QPalette::Background, QColor(240,240,240));
    setAutoFillBackground(true);
    setPalette(Pal);

    int iLayout1 = 0;
    int iLayout2 = 0;
    QList<int> lPendingGames = QList<int>();
    for (int i = 0; i < m_pThumbnailList->length(); i++)
    {
        if (m_pThumbnailList->at(i)->GetSyncedID() != QString("")) {
            int j = FindThumbnailIndex(m_pThumbnailList->at(i)->GetSyncedID());
            if (j >= 0) {
                if (i < j)
                {
                    pHBLayout->addWidget(NewColumn(true));
                    AddThumbnail(m_pThumbnailList->at(i), pHBLayout->itemAt(pHBLayout->count()-1)->widget());
                    AddThumbnail(m_pThumbnailList->at(j), pHBLayout->itemAt(pHBLayout->count()-1)->widget());
                    if (m_pThumbnailList->at(i)->GetPlayerID() == CMainWindow::PLAYER_1)
                    {
                        iLayout1 = pHBLayout->count();
                        lPendingGames.append(iLayout1);
                    }
                    else if (m_pThumbnailList->at(i)->GetPlayerID() == CMainWindow::PLAYER_2)
                    {
                        iLayout2 = pHBLayout->count();
                        lPendingGames.append(iLayout2);
                    }
                }
                else
                {
                    if (m_pThumbnailList->at(i)->GetPlayerID() == CMainWindow::PLAYER_1)
                    {
                        iLayout1 = lPendingGames.takeFirst();
                    }
                    else if (m_pThumbnailList->at(i)->GetPlayerID() == CMainWindow::PLAYER_2)
                    {
                        iLayout2 = lPendingGames.takeFirst();
                    }
                }
            }
        }
        else if (m_pThumbnailList->at(i)->GetPlayerID() == CMainWindow::PLAYER_1)
        {
            if (iLayout1 >= pHBLayout->count())
            {
                pHBLayout->addWidget(NewColumn(false));

            }
            if (!AddThumbnail(m_pThumbnailList->at(i), pHBLayout->itemAt(iLayout1)->widget()))
            {
                pHBLayout->insertWidget(iLayout1, NewColumn(false));
                AddThumbnail(m_pThumbnailList->at(i), pHBLayout->itemAt(iLayout1)->widget());
                iLayout2++;
                for (QList<int>::Iterator g = lPendingGames.begin(); g != lPendingGames.end(); g++) {
                    (*g)++;
                }
            }
            iLayout1++;
        }
        else if (m_pThumbnailList->at(i)->GetPlayerID() == CMainWindow::PLAYER_2)
        {
            if (iLayout2 >= pHBLayout->count())
            {
                pHBLayout->addWidget(NewColumn(false));
            }
            if (!AddThumbnail(m_pThumbnailList->at(i), pHBLayout->itemAt(iLayout2)->widget()))
            {
                pHBLayout->insertWidget(iLayout2, NewColumn(false));
                AddThumbnail(m_pThumbnailList->at(i), pHBLayout->itemAt(iLayout2)->widget());
                iLayout1++;
                for (QList<int>::Iterator g = lPendingGames.begin(); g != lPendingGames.end(); g++) {
                    (*g)++;
                }
            }
            iLayout2++;
        }
        else if (m_pThumbnailList->at(i)->GetPlayerID() == CMainWindow::BOTH_PLAYER)
        {
            pHBLayout->addWidget(NewColumn(false));
            AddThumbnail(m_pThumbnailList->at(i), pHBLayout->itemAt(pHBLayout->count()-1)->widget());
            iLayout1 = pHBLayout->count();
            iLayout2 = pHBLayout->count();
        }
    }

    setLayout(pHBLayout);
}