Example #1
0
void UISettingsDialog::showEvent(QShowEvent *pEvent)
{
    /* Base-class processing: */
    QIMainDialog::showEvent(pEvent);

    /* One may think that QWidget::polish() is the right place to do things
     * below, but apparently, by the time when QWidget::polish() is called,
     * the widget style & layout are not fully done, at least the minimum
     * size hint is not properly calculated. Since this is sometimes necessary,
     * we provide our own "polish" implementation. */
    if (m_fPolished)
        return;

    m_fPolished = true;

    int iMinWidth = m_pSelector->minWidth();
#ifdef Q_WS_MAC
    /* Remove all title bar buttons (Buggy Qt): */
    ::darwinSetHidesAllTitleButtons(this);

    /* Set all size policies to ignored: */
    for (int i = 0; i < m_pStack->count(); ++i)
        m_pStack->widget(i)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
    /* Activate every single page to get the optimal size: */
    for (int i = m_pStack->count() - 1; i >= 0; --i)
    {
        m_pStack->widget(i)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
        /* Prevent this widgets to go in the Small/Mini size state which is
         * available on Mac OS X. Not sure why this happens but this seems to help
         * against. */
        QList <QWidget*> list = m_pStack->widget(i)->findChildren<QWidget*>();
        for (int a = 0; a < list.size(); ++a)
        {
            QWidget *w = list.at(a);
            if (w->parent() == m_pStack->widget(i))
                w->setFixedHeight(w->sizeHint().height());
        }
        m_pStack->setCurrentIndex(i);
        /* Now make sure the layout is freshly calculated. */
        layout()->activate();
        QSize s = minimumSize();
        if (iMinWidth > s.width())
            s.setWidth(iMinWidth);
        m_sizeList.insert(0, s);
        m_pStack->widget(i)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
    }

    sltCategoryChanged(m_pSelector->currentId());
#else /* Q_WS_MAC */
    /* Resize to the minimum possible size: */
    QSize s = minimumSize();
    if (iMinWidth > s.width())
        s.setWidth(iMinWidth);
    resize(s);
#endif /* Q_WS_MAC */
}
QSize
QFieldContainerView::QWidgetTableItem::sizeHint(void) const
{
    QWidget *pWidget = table()->cellWidget(row(), col());

    if(pWidget)
        return pWidget->sizeHint();
    else
        return QSize(10, 10);
}
Example #3
0
/*!
    \reimp
    Resize the parent window to the sizeHint
*/
void QColumnViewGrip::mouseDoubleClickEvent(QMouseEvent *event)
{
    Q_UNUSED(event);
    QWidget *parentWidget = (QWidget*)parent();
    int offset = parentWidget->sizeHint().width() - parentWidget->width();
    if (isRightToLeft())
        offset *= -1;
    moveGrip(offset);
    event->accept();
}
void BaseOrdinalPropertyWidgetQt::generateWidget() {
    signalMapperSetPropertyValue_ = new QSignalMapper(this);
    signalMapperContextMenu_ = new QSignalMapper(this);
    
    QHBoxLayout* hLayout = new QHBoxLayout(); 
    hLayout->setContentsMargins(0,0,0,0);
    hLayout->setSpacing(7);

    label_ = new EditableLabelQt(this, property_);
    hLayout->addWidget(label_);
 
    QWidget* sliderWidget = new QWidget();

    sliderWidgets_ = makeSliders(sliderWidget);

    for(size_t i = 0; i < sliderWidgets_.size(); i++) {
        sliderWidgets_[i]->setContextMenuPolicy(Qt::CustomContextMenu);
        connect(sliderWidgets_[i],
                SIGNAL(customContextMenuRequested(const QPoint&)),
                signalMapperContextMenu_,
                SLOT(map()));

        connect(sliderWidgets_[i],
                SIGNAL(valueChanged()),
                signalMapperSetPropertyValue_,
                SLOT(map()));

        signalMapperContextMenu_->setMapping(sliderWidgets_[i], static_cast<int>(i));
        signalMapperSetPropertyValue_->setMapping(sliderWidgets_[i], static_cast<int>(i));
    }

    hLayout->addWidget(sliderWidget);

    sliderWidget->setMinimumHeight(sliderWidget->sizeHint().height());
    QSizePolicy sp = sliderWidget->sizePolicy();
    sp.setVerticalPolicy(QSizePolicy::Fixed);
    sliderWidget->setSizePolicy(sp);

    connect(signalMapperContextMenu_,
            SIGNAL(mapped(int)),
            this,
            SLOT(showContextMenuSlider(int)));

    connect(signalMapperSetPropertyValue_,
            SIGNAL(mapped(int)),
            this,
            SLOT(setPropertyValue(int)));

    setLayout(hLayout);

    setFixedHeight(sizeHint().height());
    sp = sizePolicy();
    sp.setVerticalPolicy(QSizePolicy::Fixed);
    setSizePolicy(sp);
}
Example #5
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QWidget widget;
    widget.setWindowTitle(QT_VERSION_STR);

    QHBoxLayout *hLayout = new QHBoxLayout(&widget);
    QGroupBox *groupBox = new QGroupBox("QuickWidget", &widget);
    QVBoxLayout *vLayout = new QVBoxLayout(groupBox);
    QQuickWidget *quickWidget = new QQuickWidget(groupBox);
    quickWidget->setMinimumSize(360, 520);
    vLayout->addWidget(quickWidget);
    quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
    quickWidget->setSource(QUrl(QLatin1String("qrc:/main.qml")));
    if (quickWidget->status() == QQuickWidget::Error) {
        qWarning() << quickWidget->errors();
        return 1;
    }
    hLayout->addWidget(groupBox);

    const QUrl gallerySource(QLatin1String("qrc:/gallery.qml"));
    QQmlApplicationEngine engine(gallerySource);
    QObject *root = engine.rootObjects().value(0, Q_NULLPTR);
    if (!root || !root->isWindowType()) {
        qWarning() << "Load error" << gallerySource;
        return 1;
    }
    groupBox = new QGroupBox("QQuickView/createWindowContainer", &widget);
    vLayout = new QVBoxLayout(groupBox);
    QWidget *container = QWidget::createWindowContainer(qobject_cast<QWindow *>(root), groupBox);
    container->setMinimumSize(360, 520);
    vLayout->addWidget(container);
    hLayout->addWidget(groupBox);

    const QRect availableGeometry = QApplication::desktop()->availableGeometry(&widget);
    widget.move(availableGeometry.center() - QPoint(widget.sizeHint().width() / 2, widget.sizeHint().height() / 2));

    widget.show();

    return app.exec();
}
Example #6
0
void JabberSearch::setSize()
{
    if (!m_bDirty || (parent() == NULL))
        return;
    m_bDirty = false;
    for (QWidget *p = this; p; p = p->parentWidget()){
        QSize s  = p->sizeHint();
        QSize s1 = QSize(p->width(), p->height());
        p->setMinimumSize(s);
        p->resize(QMAX(s.width(), s1.width()), QMAX(s.height(), s1.height()));
        if (p->layout())
            p->layout()->invalidate();
        if (p == topLevelWidget())
            break;
    }
    QWidget *t = topLevelWidget();
    QSize s = t->sizeHint();
    t->resize(QMAX(t->width(), s.width()), QMAX(t->height(), s.height()));
    t->adjustSize();
}
Example #7
0
Q_EXPORT QSize qSmartMinSize( const QWidgetItem *i )
{
    QWidget *w = ((QWidgetItem *)i)->widget();

    QSize s( 0, 0 );
    if ( w->layout() ) {
	s = w->layout()->totalMinimumSize();
    } else {
	QSize sh;

	if ( w->sizePolicy().horData() != QSizePolicy::Ignored ) {
	    if ( w->sizePolicy().mayShrinkHorizontally() ) {
		s.setWidth( w->minimumSizeHint().width() );
	    } else {
		sh = w->sizeHint();
		s.setWidth( sh.width() );
	    }
	}

	if ( w->sizePolicy().verData() != QSizePolicy::Ignored ) {
	    if ( w->sizePolicy().mayShrinkVertically() ) {
		s.setHeight( w->minimumSizeHint().height() );
	    } else {
		s.setHeight( sh.isValid() ? sh.height()
			     : w->sizeHint().height() );
	    }
	}
    }
    s = s.boundedTo( w->maximumSize() );
    QSize min = w->minimumSize();
    if ( min.width() > 0 )
	s.setWidth( min.width() );
    if ( min.height() > 0 )
	s.setHeight( min.height() );

    if ( i->hasHeightForWidth() && min.height() == 0 && min.width() > 0 )
	s.setHeight( i->heightForWidth(s.width()) );

    s = s.expandedTo( QSize(1, 1) );
    return s;
}
Example #8
0
void MyScrollArea::setWidget(QWidget *w)
{
    widget = w;
    widget->setParent(viewport());
    if (!widget->testAttribute(Qt::WA_Resized))
        widget->resize(widget->sizeHint());

    verticalScrollBar()->setValue(0);
    verticalScrollBar()->setValue(0);

    updateArea();
}
//returns the real size hint not taking into account the visibility of the widget
QSize QToolBarAreaLayoutItem::realSizeHint() const
{
    QWidget *wid = widgetItem->widget();
    QSize s = wid->sizeHint().expandedTo(wid->minimumSizeHint());
    if (wid->sizePolicy().horizontalPolicy() == QSizePolicy::Ignored)
        s.setWidth(0);
    if (wid->sizePolicy().verticalPolicy() == QSizePolicy::Ignored)
        s.setHeight(0);
    s = s.boundedTo(wid->maximumSize())
        .expandedTo(wid->minimumSize());
    return s;
}
Example #10
0
void UIMachineViewNormal::normalizeGeometry(bool bAdjustPosition)
{
#ifndef VBOX_GUI_WITH_CUSTOMIZATIONS1
    QWidget *pTopLevelWidget = window();

    /* Make no normalizeGeometry in case we are in manual resize mode or main window is maximized: */
    if (pTopLevelWidget->isMaximized())
        return;

    /* Calculate client window offsets: */
    QRect frameGeo = pTopLevelWidget->frameGeometry();
    QRect geo = pTopLevelWidget->geometry();
    int dl = geo.left() - frameGeo.left();
    int dt = geo.top() - frameGeo.top();
    int dr = frameGeo.right() - geo.right();
    int db = frameGeo.bottom() - geo.bottom();

    /* Get the best size w/o scroll bars: */
    QSize s = pTopLevelWidget->sizeHint();

    /* Resize the frame to fit the contents: */
    s -= pTopLevelWidget->size();
    frameGeo.setRight(frameGeo.right() + s.width());
    frameGeo.setBottom(frameGeo.bottom() + s.height());

    if (bAdjustPosition)
    {
        QRegion availableGeo;
        QDesktopWidget *dwt = QApplication::desktop();
        if (dwt->isVirtualDesktop())
            /* Compose complex available region */
            for (int i = 0; i < dwt->numScreens(); ++ i)
                availableGeo += dwt->availableGeometry(i);
        else
            /* Get just a simple available rectangle */
            availableGeo = dwt->availableGeometry(pTopLevelWidget->pos());

        frameGeo = VBoxGlobal::normalizeGeometry(frameGeo, availableGeo, vboxGlobal().vmRenderMode() != SDLMode /* can resize? */);
    }

#if 0
    /* Center the frame on the desktop: */
    frameGeo.moveCenter(availableGeo.center());
#endif

    /* Finally, set the frame geometry */
    pTopLevelWidget->setGeometry(frameGeo.left() + dl, frameGeo.top() + dt, frameGeo.width() - dl - dr, frameGeo.height() - dt - db);

#else /* !VBOX_GUI_WITH_CUSTOMIZATIONS1 */
    Q_UNUSED(bAdjustPosition);
#endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */
}
Example #11
0
void ItemWidget::updateSize(const QSize &maximumSize, int idealWidth)
{
    QWidget *w = widget();
    w->setMaximumSize(maximumSize);
    const int idealHeight = w->heightForWidth(idealWidth);
    const int maximumHeight = w->heightForWidth(maximumSize.width());
    if (idealHeight <= 0 && maximumHeight <= 0)
        w->resize(w->sizeHint());
    else if (idealHeight != maximumHeight)
        w->setFixedSize( maximumSize.width(), maximumHeight );
    else
        w->setFixedSize(idealWidth, idealHeight);
}
Example #12
0
Q_EXPORT QSize qSmartMaxSize( const QWidgetItem *i, int align )
{
    QWidget *w = ( (QWidgetItem*)i )->widget();
    if ( align & Qt::AlignHorizontal_Mask && align & Qt::AlignVertical_Mask )
	return QSize( QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX );
    QSize s = w->maximumSize();
    if ( s.width() == QWIDGETSIZE_MAX && !(align & Qt::AlignHorizontal_Mask) )
	if ( !w->sizePolicy().mayGrowHorizontally() )
	    s.setWidth( w->sizeHint().width() );

    if ( s.height() == QWIDGETSIZE_MAX && !(align & Qt::AlignVertical_Mask) )
	if ( !w->sizePolicy().mayGrowVertically() )
	    s.setHeight( w->sizeHint().height() );

    s = s.expandedTo( w->minimumSize() );

    if ( align & Qt::AlignHorizontal_Mask )
	s.setWidth( QLAYOUTSIZE_MAX );
    if ( align & Qt::AlignVertical_Mask )
	s.setHeight( QLAYOUTSIZE_MAX );
    return s;
}
Example #13
0
void Dialog::prepareView()
{
	// Make sure the dialog controls are correctly enabled/disabled with
	// readonly status.
	checkStatus();

	QWidget * w = asQWidget();
	w->setWindowTitle(title_);

	QSize const hint = w->sizeHint();
	if (hint.height() >= 0 && hint.width() >= 0)
		w->setMinimumSize(hint);
}
Example #14
0
 void setTag(const ItemTags::Tag &tag)
 {
     if ( isTagValid(tag) ) {
         QWidget tagWidget;
         initTagWidget(&tagWidget, tag, smallerFont(QFont()));
         m_pixmap = QPixmap(tagWidget.sizeHint());
         m_pixmap.fill(Qt::transparent);
         QPainter painter(&m_pixmap);
         tagWidget.render(&painter);
     } else {
         m_pixmap = QPixmap();
     }
 }
Example #15
0
void PorkMarket::show_text(const QString &message)
{
    QStringList list = message.split("|",QString::SkipEmptyParts);

    QWidget* w = new QWidget();
    QVBoxLayout* vbl = new QVBoxLayout(w);

    QHBoxLayout* top = new QHBoxLayout(w);
    QDateTime current_date_time = QDateTime::currentDateTime();
    QString current_date = current_date_time.toString("yyyy-MM-dd hh:mm:ss");
    QLabel* lab_time = new QLabel(current_date);
    top->addWidget(lab_time);
    if(list.size()>3)
    {
      QLabel* lab_price = new QLabel("price:"+list[2]+"XPC");
      top->addWidget(lab_price);
    }
    vbl->addLayout(top);

    QLabel* lab_image = new QLabel;
    QImage  image;
    if(list.size()>1)
    image.loadFromData(QByteArray::fromBase64(list[1].toLatin1()));
    lab_image->setPixmap(QPixmap::fromImage(image));
    QLabel* lab_content = new QLabel(list[0]);
    lab_content->setAlignment(Qt::AlignLeft|Qt::AlignTop);
    lab_content->setMidLineWidth(600);
    lab_content->setWordWrap(true);

    QHBoxLayout* bottom = new QHBoxLayout(w);
    bottom->setSizeConstraint(QLayout::SetFixedSize);
    bottom->addWidget(lab_image);
    bottom->addWidget(lab_content);

    vbl->addLayout(bottom);
    vbl->setSizeConstraint( QLayout::SetFixedSize );
    w->setLayout(vbl);
    QListWidgetItem* lwi = new QListWidgetItem;

    lwi->setSizeHint( w->sizeHint() );
    ui->listWidget->addItem(lwi);
    ui->listWidget->setItemWidget(lwi, w);

    lwi->setData(4,QVariant(list[0]));
    lwi->setData(1,QVariant(list[1]));
    lwi->setData(5,QVariant(list[2]));
    lwi->setData(3,QVariant(list[3]));
    lwi->setData(2,QVariant(""));
}
Example #16
0
void ToolTipManager::showToolTip( QModelIndex menuItem )
{
    if (QApplication::mouseButtons() & Qt::LeftButton) {
        return;
    }

    QWidget * tip = createTipContent( menuItem );

    // calculate the x- and y-position of the tooltip
    const QSize size = tip->sizeHint();
    const QRect desktop = QApplication::desktop()->screenGeometry( d->itemRect.bottomRight() );

    // d->itemRect defines the area of the item, where the tooltip should be
    // shown. Per default the tooltip is shown in the bottom right corner.
    // If the tooltip content exceeds the desktop borders, it must be assured that:
    // - the content is fully visible
    // - the content is not drawn inside d->itemRect
    const int margin = 3;
    const bool hasRoomToLeft  = (d->itemRect.left()   - size.width() - margin >= desktop.left());
    const bool hasRoomToRight = (d->itemRect.right()  + size.width() + margin <= desktop.right());
    const bool hasRoomAbove   = (d->itemRect.top()    - size.height() - margin >= desktop.top());
    const bool hasRoomBelow   = (d->itemRect.bottom() + size.height() + margin <= desktop.bottom());
    if (!hasRoomAbove && !hasRoomBelow && !hasRoomToLeft && !hasRoomToRight) {
        delete tip;
        tip = 0;
        return;
    }

    int x = 0;
    int y = 0;
    if (hasRoomBelow || hasRoomAbove) {
        x = qMax(desktop.left(), d->itemRect.center().x() - size.width() / 2);
        if (x + size.width() / 2 >= desktop.right()) {
            x = desktop.right() - size.width();
        }

        y = hasRoomBelow ? d->itemRect.bottom() + margin : d->itemRect.top() - size.height() - margin;
    } else {
        Q_ASSERT(hasRoomToLeft || hasRoomToRight);
        x = hasRoomToRight ? d->itemRect.right() + margin : d->itemRect.left() - size.width() - margin;

        // Put the tooltip at the bottom of the screen. The x-coordinate has already
        // been adjusted, so that no overlapping with d->itemRect occurs.
        y = desktop.bottom() - size.height();
    }

    // the ownership of tip is transferred to KToolTip
    KToolTip::showTip(QPoint(x, y), tip);
}
Example #17
0
void AdvanceButtonDialog::appendBlankKeyGrabber()
{
    SimpleKeyGrabberButton *blankButton = new SimpleKeyGrabberButton(this);
    QListWidgetItem *item = new QListWidgetItem();
    ui->slotListWidget->addItem(item);
    item->setData(Qt::UserRole, QVariant::fromValue<SimpleKeyGrabberButton*>(blankButton));
    QHBoxLayout *layout= new QHBoxLayout();
    layout->addWidget(blankButton);
    QWidget *widget = new QWidget();
    widget->setLayout(layout);
    item->setSizeHint(widget->sizeHint());
    ui->slotListWidget->setItemWidget(item, widget);
    ui->slotListWidget->setCurrentItem(item);
    connectButtonEvents(blankButton);
}
QSize
QDialogButtons::sizeHint(QDialogButtons::Button button) const
{
    QWidget *w = NULL;
    if(d->visible & button) {
	if(!d->buttons.contains(button)) {
	    QDialogButtons *that = (QDialogButtons*)this; //ick, constness..
	    w = that->createButton(button);
	    that->d->buttons.insert(button, w);
	} else {
	    w = d->buttons[button];
	}
    }
    return w->sizeHint();
}
Example #19
0
PluginCfg::PluginCfg(QWidget *parent, const QString& pluginname) : QWidget(parent)
{
	setupUi(this);
    m_pluginName = pluginname;
	if(ProfileManager::instance()->currentProfile()->enabledPlugins().contains(m_pluginName) ||
			getPluginManager()->isPluginAlwaysEnabled(m_pluginName))
	{
		PluginPtr plugin = getPluginManager()->plugin(pluginname);
        QWidget *w = plugin->createConfigWindow(addWnd);
        if (w){
            QVBoxLayout *lay = new QVBoxLayout(addWnd);
            lay->addWidget(w);
            QObject::connect(parent->topLevelWidget(), SIGNAL(applyChanges()), w, SLOT(apply()));
            // adjust plugin widget
            w->setMinimumSize(w->sizeHint());
            w->adjustSize();
            // adjust addWnd widget
            addWnd->setMinimumSize(addWnd->sizeHint());
            addWnd->adjustSize();
        }
    }
    // adjust description
    if(!getPluginManager()->pluginDescription(pluginname).isNull())
	{
        lblDescription->setText(i18n(getPluginManager()->pluginDescription(pluginname)));
    }
	else
	{
        lblDescription->setText("");
    }
    // adjust tab
    tabWnd->setCurrentIndex(0);
    tabWnd->setTabText(0, i18n(getPluginManager()->pluginTitle(pluginname)));
    tabWnd->setMinimumSize(tabWnd->sizeHint());
    tabWnd->adjustSize();
    // adjust complete widget
    setMinimumSize(sizeHint());
    adjustSize();
    if (getPluginManager()->isPluginAlwaysEnabled(pluginname)) {
        chkEnable->hide();
	} else {
		chkEnable->setEnabled(true);
		chkEnable->setChecked(ProfileManager::instance()->currentProfile()->enabledPlugins().contains(pluginname));
	}
}
Example #20
0
/*!
    \reimp
*/
QSize QSplitter::sizeHint() const
{
    Q_D(const QSplitter);
    ensurePolished();
    int l = 0;
    int t = 0;
    for (int i = 0; i < d->list.size(); ++i) {
        QWidget *w = d->list.at(i)->widget;
        if (w->isHidden())
            continue;
        QSize s = w->sizeHint();
        if (s.isValid()) {
            l += d->pick(s);
            t = qMax(t, d->trans(s));
        }
    }
    return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l);
}
Example #21
0
PluginCfg::PluginCfg(QWidget *parent, pluginInfo *info)
        : PluginCfgBase(parent)
{
    m_info = info;
    if (m_info->plugin){
        QWidget *w = m_info->plugin->createConfigWindow(addWnd);
        if (w){
            QVBoxLayout *lay = new QVBoxLayout(addWnd);
            lay->addWidget(w);
            QObject::connect(parent->topLevelWidget(), SIGNAL(applyChanges()), w, SLOT(apply()));
            // adjust plugin widget
            w->setMinimumSize(w->sizeHint());
            w->adjustSize();
            // adjust addWnd widget
            addWnd->setMinimumSize(addWnd->sizeHint());
            addWnd->adjustSize();
        }
    }
    // adjust description
    if (m_info->info && m_info->info->description){
        lblDescription->setText(i18n(m_info->info->description));
    }else{
        lblDescription->setText("");
    }
    // adjust tab
    tabWnd->setCurrentPage(0);
    tabWnd->changeTab(tabWnd->currentPage(), i18n(m_info->info->title));
    tabWnd->setMinimumSize(tabWnd->sizeHint());
    tabWnd->adjustSize();
    // adjust complete widget
    setMinimumSize(sizeHint());
    adjustSize();
    if (m_info->info && (m_info->info->flags & PLUGIN_NODISABLE)){
        chkEnable->hide();
    }else{
        if (m_info->bNoCreate){
            chkEnable->setEnabled(false);
            chkEnable->setChecked(false);
        }else{
            chkEnable->setEnabled(true);
            chkEnable->setChecked(!m_info->bDisabled);
        }
    }
}
void KexiPasswordWidget::addCommentLine( const QString& label,
                                      const QString& comment )
{
    int gridMarginLeft, gridMarginTop, gridMarginRight, gridMarginBottom;
    d->ui.formLayout->getContentsMargins(&gridMarginLeft, &gridMarginTop, &gridMarginRight, &gridMarginBottom);

    int spacing = d->ui.formLayout->horizontalSpacing();
    if (spacing < 0) {
        // same inter-column spacing for all rows, see comment in qformlayout.cpp
        spacing = style()->combinedLayoutSpacing(QSizePolicy::Label, QSizePolicy::LineEdit, Qt::Horizontal, 0, this);
    }

    QLabel* c = new QLabel(comment, this);
    c->setWordWrap(true);

    d->ui.formLayout->insertRow(d->commentRow, label, c);
    ++d->commentRow;

    // cycle through column 0 widgets and see the max width so we can set the minimum height of
    // column 2 wordwrapable labels
    int firstColumnWidth = 0;
    for (int i = 0; i < d->ui.formLayout->rowCount(); ++i) {
        QLayoutItem *li = d->ui.formLayout->itemAt(i, QFormLayout::LabelRole);
        if (li) {
            QWidget *w = li->widget();
            if (w && !w->isHidden()) {
                firstColumnWidth = qMax(firstColumnWidth, w->sizeHint().width());
            }
        }
    }
    for (int i = 0; i < d->ui.formLayout->rowCount(); ++i) {
        QLayoutItem *li = d->ui.formLayout->itemAt(i, QFormLayout::FieldRole);
        if (li) {
            QLabel *l = qobject_cast<QLabel*>(li->widget());
            if (l && l->wordWrap()) {
                int w = sizeHint().width() - firstColumnWidth - ( 2 * KDialog::marginHint() )
                        - gridMarginLeft - gridMarginRight - spacing;
                l->setMinimumSize( w, l->heightForWidth(w) );
            }
        }
    }
}
void PorkMarket::show_text(const std::string &message)
{
    QString mes=QString::fromStdString(message);
    QStringList list = mes.split("|",QString::SkipEmptyParts);

    OutputDebugStringF("show_text");
    printf("---");

    QWidget* w = new QWidget();


    QVBoxLayout* vbl = new QVBoxLayout(w);
    QDateTime current_date_time = QDateTime::currentDateTime();
    QString current_date = current_date_time.toString("yyyy-MM-dd hh:mm:ss");
    QLabel* lab_01 = new QLabel(current_date);
    QLabel* lab_02 = new QLabel(current_date);
    vbl->addWidget(lab_01);
    w->setLayout(vbl);


//    QListWidgetItem* lwi = new QListWidgetItem;
//    lwi->setSizeHint( w->sizeHint() );
//    ui->listWidget->addItem(lwi);
//    ui->listWidget->setItemWidget(lwi, w);
//    return;





    QHBoxLayout* Hbl = new QHBoxLayout(w);
    Hbl->addWidget(lab_02);
//    Hbl->addWidget(lab_03);
    vbl->addLayout(Hbl);
    vbl->setSizeConstraint( QLayout::SetFixedSize );


    QListWidgetItem* lwi = new QListWidgetItem;
    lwi->setSizeHint( w->sizeHint() );
    ui->listWidget->addItem(lwi);
    ui->listWidget->setItemWidget(lwi, w);
}
//************************************************************************************************
//************************************** class ZFileSaveDialog ***********************************
//************************************************************************************************
ZFileSaveDialog::ZFileSaveDialog()
  :MyBaseDlg()
{
  QWidget *myWidget = new QWidget ( this );
  QVBoxLayout *myVBoxLayout = new QVBoxLayout ( myWidget, 0 );
  
  // label
  QLabel *myLabel = new QLabel ( QString ( "Filename to save:" ), myWidget );
  myVBoxLayout->addWidget ( myLabel, 0 );
  myLabel->setIndent ( 5 );
  myLabel->setAutoResize ( true );
    
  // zlineedit
  zmle = new ZMultiLineEdit(myWidget, true, 1, "ZMultiLineEdit");
  zmle->setEdited(false);
  zmle->setFixedHeight(myWidget->sizeHint().height());
  zmle->setInsertionMethod ( ( ZMultiLineEdit::InsertionMethod ) 3 );
  zmle->setFontPercent ( 0.7 );
  zmle->setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
  zmle->setCellHeight(22);

  
  myVBoxLayout->addWidget ( zmle, 1 );
  
  fb = new FileBrowser("*", QString ( "%I%M" ), myWidget, 0, ( ZSkinService::WidgetClsID ) 4);
  fb->setDir("/");
  QObject::connect(fb, SIGNAL(isFilePicked(bool)), SLOT(filePicked(bool)));
  myVBoxLayout->addWidget ( fb, 1 );
  
  
  setContentWidget ( myWidget );
  
  ZSoftKey *softKey = new ZSoftKey ( NULL, this, this );
  ZConfig IDini("/tmp/Z6ManagerLang", false);
  QString IDval = IDini.readEntry(QString("Z6MANAGER"), QString("MENU_SELECT"), "");
  softKey->setText ( ZSoftKey::LEFT, IDval, ( ZSoftKey::TEXT_PRIORITY ) 0 );
  IDval = IDini.readEntry(QString("Z6MANAGER"), QString("MENU_CANCEL"), "");
  softKey->setText ( ZSoftKey::RIGHT, IDval, ( ZSoftKey::TEXT_PRIORITY ) 0 );
  softKey->setClickedSlot ( ZSoftKey::RIGHT, this, SLOT ( reject() ) );
  softKey->setClickedSlot ( ZSoftKey::LEFT, this, SLOT ( accept() ) );
  setCSTWidget ( softKey );
}
Example #25
0
/*!
    \fn OptToolBar::initToolBar()
 */
void OptToolBar::initToolBar()
{
  mColSize = 2;
  mCol = 0;
  mRow = 0;

  buttonGroup = new QButtonGroup;

  connect(buttonGroup, SIGNAL(buttonClicked(int)),
             this, SLOT(buttonGroupClicked(int)));
  mLayout = new QGridLayout;
  mLayout->setSpacing(2);
  mLayout->setMargin(5);
  QWidget *dockWidgetContents = new QWidget();

  dockWidgetContents->setLayout(mLayout);

  setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
  setMinimumWidth(dockWidgetContents->sizeHint().width());
  setWidget( dockWidgetContents );
}
Example #26
0
void AdvanceButtonDialog::insertSlot()
{
    int current = ui->slotListWidget->currentRow();
    int count = ui->slotListWidget->count();

    if (current != (count - 1))
    {
        SimpleKeyGrabberButton *blankButton = new SimpleKeyGrabberButton(this);
        QListWidgetItem *item = new QListWidgetItem();
        ui->slotListWidget->insertItem(current, item);
        item->setData(Qt::UserRole, QVariant::fromValue<SimpleKeyGrabberButton*>(blankButton));
        QHBoxLayout *layout= new QHBoxLayout();
        layout->addWidget(blankButton);
        QWidget *widget = new QWidget();
        widget->setLayout(layout);
        item->setSizeHint(widget->sizeHint());
        ui->slotListWidget->setItemWidget(item, widget);
        ui->slotListWidget->setCurrentItem(item);
        connectButtonEvents(blankButton);
    }
}
void InternetViewContainer::ServiceChanged(const QModelIndex& index) {
  InternetService* service =
      index.data(InternetModel::Role_Service).value<InternetService*>();
  if (!service || service == current_service_) return;
  current_service_ = service;

  QWidget* header = service->HeaderWidget();
  if (header && !headers_.contains(header)) {
    header->setParent(ui_->header_container);
    header->setMaximumHeight(0);
    ui_->header_container->layout()->addWidget(header);
    header->show();

    HeaderData d;
    d.visible_ = false;
    d.animation_ = new QTimeLine(kAnimationDuration, this);
    d.animation_->setFrameRange(0, header->sizeHint().height());
    connect(d.animation_, SIGNAL(frameChanged(int)),
            SLOT(SetHeaderHeight(int)));

    headers_.insert(header, d);
  }
//************************************************************************************************
//************************************** class ZFileSaveDialog ***********************************
//************************************************************************************************
ZFileSaveDialog::ZFileSaveDialog(const QString &curPath, const QString &originName)
  :MyBaseDlg()
{
  QWidget *myWidget = new QWidget ( this );
  QVBoxLayout *myVBoxLayout = new QVBoxLayout ( myWidget, 0 );
  
  // label
  QLabel *myLabel = new QLabel ( QString ( "Nombre para guardar:" ), myWidget );
  myVBoxLayout->addWidget ( myLabel, 0 );
  myLabel->setIndent ( 5 );
  myLabel->setAutoResize ( true );
    
  // zlineedit
  zmle = new ZMultiLineEdit(myWidget, true, 1, "ZMultiLineEdit");
  zmle->setEdited(false);
  zmle->setFixedHeight(myWidget->sizeHint().height());
  zmle->setInsertionMethod ( ( ZMultiLineEdit::InsertionMethod ) 3 );
  zmle->setFontPercent ( 0.7 );
  zmle->setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
  //zmle->setCellHeight(22);
  zmle->setText(originName);
  
  myVBoxLayout->addWidget ( zmle, 1 );
  
  fb = new FileBrowser("*", QString ( "%I%M" ), myWidget, 0);
  fb->setDir(curPath);
  QObject::connect(fb, SIGNAL(isFilePicked(bool)), SLOT(filePicked(bool)));
  myVBoxLayout->addWidget ( fb, 1 );
  
  
  setContentWidget ( myWidget );
  
  ZSoftKey *softKey = new ZSoftKey ( NULL, this, this );
  softKey->setText ( ZSoftKey::LEFT, "Guardar", ( ZSoftKey::TEXT_PRIORITY ) 0 );
  softKey->setText ( ZSoftKey::RIGHT, "Cancelar", ( ZSoftKey::TEXT_PRIORITY ) 0 );
  softKey->setClickedSlot ( ZSoftKey::RIGHT, this, SLOT ( reject() ) );
  softKey->setClickedSlot ( ZSoftKey::LEFT, this, SLOT ( accept() ) );
  setCSTWidget ( softKey );
}
QLabel* AbstractStatisticsWidget::addStatisticLabel
(
    const QString& description,
    const QString& initialValue,
    const QString& toolTip
)
{
    QHBoxLayout* layout = new QHBoxLayout();
    layout->setContentsMargins(2, 2, 2, 2);

    QLabel* descriptionLabel = new QLabel(description);
    descriptionLabel->setAlignment(Qt::AlignRight);

    QLabel* valueLabel = new QLabel(QString("<b>%1</b>").arg(initialValue));

    valueLabel->setTextFormat(Qt::RichText);
    valueLabel->setAlignment(Qt::AlignLeft);

    layout->addWidget(descriptionLabel);
    layout->addWidget(valueLabel);
    layout->setSizeConstraint(QLayout::SetMinimumSize);

    QWidget* containerWidget = new QWidget();
    containerWidget->setLayout(layout);

    QListWidgetItem* item = new QListWidgetItem();
    item->setSizeHint(containerWidget->sizeHint());

    this->addItem(item);
    this->setItemWidget(item, containerWidget);

    if (!toolTip.isNull())
    {
        descriptionLabel->setToolTip(toolTip);
        valueLabel->setToolTip(toolTip);
    }

    return valueLabel;
}
Example #30
0
ProxyConfig::ProxyConfig(QWidget *parent, ProxyPlugin *plugin, QTabWidget *tab, Client *client)
        : QWidget( parent)
{
    setupUi( this);
    m_plugin = plugin;
    m_client = client;
    m_current = (unsigned)(-1);
    cmbType->insertItem(i18n("None"));
    cmbType->insertItem("SOCKS4");
    cmbType->insertItem("SOCKS5");
    cmbType->insertItem("HTTP/HTTPS");
    if (tab){
        tab->addTab(this, i18n("&Proxy"));
        for (QWidget *p = this; p; p = p->parentWidget()){
            QSize s  = p->sizeHint();
            QSize s1 = QSize(p->width(), p->height());
            p->setMinimumSize(s);
            p->resize(QMAX(s.width(), s1.width()), QMAX(s.height(), s1.height()));
            if (p->layout())
                p->layout()->invalidate();
            if (p == topLevelWidget())
                break;
        }
    }
    connect(cmbType, SIGNAL(activated(int)), this, SLOT(typeChanged(int)));
    connect(chkAuth, SIGNAL(toggled(bool)), this, SLOT(authToggled(bool)));
    if (m_client){
        lblClient->hide();
        cmbClient->hide();
        ProxyData data;
        plugin->clientData(static_cast<TCPClient*>(m_client), data);
        fill(&data);
    }else{
        fillClients();
        connect(cmbClient, SIGNAL(activated(int)), this, SLOT(clientChanged(int)));
        clientChanged(0);
    }
}